update schema

This commit is contained in:
2021-10-03 19:19:48 +03:00
parent 0a9949caa3
commit 633c07d58d
4 changed files with 15 additions and 14 deletions

View File

@@ -15,7 +15,7 @@ users_dict = json.loads(open(abspath('migration/data/users.dict.json')).read())
users_dict['0'] = {
'id': 9999999,
'slug': 'discours',
'viewname': 'Дискурс',
'name': 'Дискурс',
'userpic': 'https://discours.io/images/logo-mini.svg'
}
@@ -118,7 +118,7 @@ def migrate(entry, limit=3626, start=0):
try:
userdata = users_dict[entry['createdBy']]
slug = userdata['slug']
name = userdata['viewname']
name = userdata['name']
userpic = userdata['userpic']
except KeyError:
app = entry.get('application')
@@ -126,7 +126,7 @@ def migrate(entry, limit=3626, start=0):
authordata = {
'username': app['email'],
'email': app['email'],
'viewname': app['name'],
'name': app['name'],
'bio': app.get('bio', ''),
'emailConfirmed': False,
'slug': translit(app['name'], 'ru', reversed=True).replace(' ', '-').lower(),
@@ -142,7 +142,7 @@ def migrate(entry, limit=3626, start=0):
user = session.query(User).filter(User.slug == authordata['slug']).first()
slug = user.slug
name = user.viewname
name = user.name
userpic = user.userpic
else:
# no application, no author!

View File

@@ -15,7 +15,7 @@ def migrate(entry, limit=668):
email: String
password: String
oauth: String # provider:token
viewname: String # to display
name: String # to display
userpic: String
links: [String]
emailConfirmed: Boolean # should contain all emails too
@@ -52,11 +52,11 @@ def migrate(entry, limit=668):
res['userpic'] = entry['profile'].get('image', {'thumborId': ''}).get('thumborId', '') # adding 'https://assets.discours.io/unsafe/1600x' in web ui
fn = entry['profile'].get('firstName', '')
ln = entry['profile'].get('lastName', '')
viewname = res['slug'] if res['slug'] else 'anonymous'
viewname = fn if fn else viewname
viewname = (viewname + ' ' + ln) if ln else viewname
viewname = entry['profile']['path'] if len(viewname) < 2 else viewname
res['viewname'] = viewname
name = res['slug'] if res['slug'] else 'anonymous'
name = fn if fn else name
name = (name + ' ' + ln) if ln else name
name = entry['profile']['path'] if len(name) < 2 else name
res['name'] = name
fb = entry['profile'].get('facebook', False)
if fb:
res['links'].append(fb)