update schema
This commit is contained in:
parent
0a9949caa3
commit
633c07d58d
|
@ -15,7 +15,7 @@ users_dict = json.loads(open(abspath('migration/data/users.dict.json')).read())
|
||||||
users_dict['0'] = {
|
users_dict['0'] = {
|
||||||
'id': 9999999,
|
'id': 9999999,
|
||||||
'slug': 'discours',
|
'slug': 'discours',
|
||||||
'viewname': 'Дискурс',
|
'name': 'Дискурс',
|
||||||
'userpic': 'https://discours.io/images/logo-mini.svg'
|
'userpic': 'https://discours.io/images/logo-mini.svg'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ def migrate(entry, limit=3626, start=0):
|
||||||
try:
|
try:
|
||||||
userdata = users_dict[entry['createdBy']]
|
userdata = users_dict[entry['createdBy']]
|
||||||
slug = userdata['slug']
|
slug = userdata['slug']
|
||||||
name = userdata['viewname']
|
name = userdata['name']
|
||||||
userpic = userdata['userpic']
|
userpic = userdata['userpic']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
app = entry.get('application')
|
app = entry.get('application')
|
||||||
|
@ -126,7 +126,7 @@ def migrate(entry, limit=3626, start=0):
|
||||||
authordata = {
|
authordata = {
|
||||||
'username': app['email'],
|
'username': app['email'],
|
||||||
'email': app['email'],
|
'email': app['email'],
|
||||||
'viewname': app['name'],
|
'name': app['name'],
|
||||||
'bio': app.get('bio', ''),
|
'bio': app.get('bio', ''),
|
||||||
'emailConfirmed': False,
|
'emailConfirmed': False,
|
||||||
'slug': translit(app['name'], 'ru', reversed=True).replace(' ', '-').lower(),
|
'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()
|
user = session.query(User).filter(User.slug == authordata['slug']).first()
|
||||||
|
|
||||||
slug = user.slug
|
slug = user.slug
|
||||||
name = user.viewname
|
name = user.name
|
||||||
userpic = user.userpic
|
userpic = user.userpic
|
||||||
else:
|
else:
|
||||||
# no application, no author!
|
# no application, no author!
|
||||||
|
|
|
@ -15,7 +15,7 @@ def migrate(entry, limit=668):
|
||||||
email: String
|
email: String
|
||||||
password: String
|
password: String
|
||||||
oauth: String # provider:token
|
oauth: String # provider:token
|
||||||
viewname: String # to display
|
name: String # to display
|
||||||
userpic: String
|
userpic: String
|
||||||
links: [String]
|
links: [String]
|
||||||
emailConfirmed: Boolean # should contain all emails too
|
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
|
res['userpic'] = entry['profile'].get('image', {'thumborId': ''}).get('thumborId', '') # adding 'https://assets.discours.io/unsafe/1600x' in web ui
|
||||||
fn = entry['profile'].get('firstName', '')
|
fn = entry['profile'].get('firstName', '')
|
||||||
ln = entry['profile'].get('lastName', '')
|
ln = entry['profile'].get('lastName', '')
|
||||||
viewname = res['slug'] if res['slug'] else 'anonymous'
|
name = res['slug'] if res['slug'] else 'anonymous'
|
||||||
viewname = fn if fn else viewname
|
name = fn if fn else name
|
||||||
viewname = (viewname + ' ' + ln) if ln else viewname
|
name = (name + ' ' + ln) if ln else name
|
||||||
viewname = entry['profile']['path'] if len(viewname) < 2 else viewname
|
name = entry['profile']['path'] if len(name) < 2 else name
|
||||||
res['viewname'] = viewname
|
res['name'] = name
|
||||||
fb = entry['profile'].get('facebook', False)
|
fb = entry['profile'].get('facebook', False)
|
||||||
if fb:
|
if fb:
|
||||||
res['links'].append(fb)
|
res['links'].append(fb)
|
||||||
|
|
|
@ -45,7 +45,7 @@ class User(Base):
|
||||||
password: str = Column(String, nullable=True, comment="Password")
|
password: str = Column(String, nullable=True, comment="Password")
|
||||||
bio: str = Column(String, nullable=True, comment="Bio")
|
bio: str = Column(String, nullable=True, comment="Bio")
|
||||||
userpic: str = Column(String, nullable=True, comment="Userpic")
|
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")
|
rating: int = Column(Integer, nullable=True, comment="Rating")
|
||||||
slug: str = Column(String, unique=True, comment="User's slug")
|
slug: str = Column(String, unique=True, comment="User's slug")
|
||||||
muted: bool = Column(Boolean, default=False)
|
muted: bool = Column(Boolean, default=False)
|
||||||
|
|
|
@ -155,7 +155,7 @@ type User {
|
||||||
username: String! # email
|
username: String! # email
|
||||||
createdAt: DateTime!
|
createdAt: DateTime!
|
||||||
slug: String!
|
slug: String!
|
||||||
viewname: String # to display
|
name: String # to display
|
||||||
email: String
|
email: String
|
||||||
password: String
|
password: String
|
||||||
oauth: String # provider:token
|
oauth: String # provider:token
|
||||||
|
@ -239,10 +239,11 @@ type Community {
|
||||||
|
|
||||||
type Topic {
|
type Topic {
|
||||||
slug: String! # ID
|
slug: String! # ID
|
||||||
|
title: String
|
||||||
|
body: String
|
||||||
|
pic: String
|
||||||
createdBy: Int! # User
|
createdBy: Int! # User
|
||||||
createdAt: DateTime!
|
createdAt: DateTime!
|
||||||
value: String
|
|
||||||
desc: String
|
|
||||||
parents: [String] # NOTE: topic can have parent topics
|
parents: [String] # NOTE: topic can have parent topics
|
||||||
children: [String] # and children
|
children: [String] # and children
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user