From 633c07d58d5a42378ea833182379695e3668d89d Mon Sep 17 00:00:00 2001 From: Untone Date: Sun, 3 Oct 2021 19:19:48 +0300 Subject: [PATCH] update schema --- migration/tables/content_items.py | 8 ++++---- migration/tables/users.py | 12 ++++++------ orm/user.py | 2 +- schema.graphql | 7 ++++--- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/migration/tables/content_items.py b/migration/tables/content_items.py index a3980af8..68416b4d 100644 --- a/migration/tables/content_items.py +++ b/migration/tables/content_items.py @@ -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! diff --git a/migration/tables/users.py b/migration/tables/users.py index ffb918c6..5443f783 100644 --- a/migration/tables/users.py +++ b/migration/tables/users.py @@ -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) diff --git a/orm/user.py b/orm/user.py index 831ee84c..289fc577 100644 --- a/orm/user.py +++ b/orm/user.py @@ -45,7 +45,7 @@ class User(Base): password: str = Column(String, nullable=True, comment="Password") bio: str = Column(String, nullable=True, comment="Bio") userpic: str = Column(String, nullable=True, comment="Userpic") - viewname: str = Column(String, nullable=True, comment="Display name") + name: str = Column(String, nullable=True, comment="Display name") rating: int = Column(Integer, nullable=True, comment="Rating") slug: str = Column(String, unique=True, comment="User's slug") muted: bool = Column(Boolean, default=False) diff --git a/schema.graphql b/schema.graphql index b2928870..b93b115f 100644 --- a/schema.graphql +++ b/schema.graphql @@ -155,7 +155,7 @@ type User { username: String! # email createdAt: DateTime! slug: String! - viewname: String # to display + name: String # to display email: String password: String oauth: String # provider:token @@ -239,10 +239,11 @@ type Community { type Topic { slug: String! # ID + title: String + body: String + pic: String createdBy: Int! # User createdAt: DateTime! - value: String - desc: String parents: [String] # NOTE: topic can have parent topics children: [String] # and children }