some fixes
This commit is contained in:
parent
8af36f094d
commit
68212b4ecf
|
@ -116,7 +116,7 @@ async def shouts_handle(storage, args):
|
|||
topics_dataset_bodies.append(u" ".join([x.strip().lower() for x in texts]))
|
||||
topics_dataset_tlist.append(shout['topics'])
|
||||
|
||||
np.savetxt('topics_dataset.csv', (topics_dataset_bodies, topics_dataset_tlist), delimiter=',', fmt='%s')
|
||||
# np.savetxt('topics_dataset.csv', (topics_dataset_bodies, topics_dataset_tlist), delimiter=',', fmt='%s')
|
||||
|
||||
print('[migration] ' + str(counter) + ' content items were migrated')
|
||||
print('[migration] ' + str(pub_counter) + ' have been published')
|
||||
|
@ -160,10 +160,10 @@ def bson_handle():
|
|||
bson2json.json_tables()
|
||||
|
||||
|
||||
def export_one(slug, storage):
|
||||
def export_one(slug, storage, args = None):
|
||||
topics_handle(storage)
|
||||
users_handle(storage)
|
||||
shouts_handle(storage)
|
||||
shouts_handle(storage, args)
|
||||
export_slug(slug, storage)
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from logging import exception
|
||||
from migration.extract import extract_md, html2text
|
||||
from base.orm import local_session
|
||||
from orm import Topic, Community
|
||||
|
@ -14,15 +15,14 @@ def migrate(entry):
|
|||
topic_dict['body'] = extract_md(html2text(body_orig), entry['_id'])
|
||||
with local_session() as session:
|
||||
slug = topic_dict['slug']
|
||||
topic = session.query(Topic).filter(Topic.slug == slug).first()
|
||||
if not topic:
|
||||
topic = Topic.create(**topic_dict)
|
||||
if len(topic.title) > len(topic_dict['title']):
|
||||
topic.update({ 'title': topic_dict['title'] })
|
||||
if len(topic.body) < len(topic_dict['body']):
|
||||
topic.update({ 'body': topic_dict['body'] })
|
||||
session.commit()
|
||||
t: Topic = session.query(Topic).filter(Topic.slug == slug).first() or Topic.create(**topic_d) or raise Exception('topic not created') # type: ignore
|
||||
if t:
|
||||
if len(t.title) > len(topic_dict['title']):
|
||||
Topic.update(t, {'title': topic_dict['title']})
|
||||
if len(t.body) < len(topic_dict['body']):
|
||||
Topic.update(t, { 'body': topic_dict['body'] })
|
||||
session.commit()
|
||||
# print(topic.__dict__)
|
||||
rt = topic.__dict__.copy()
|
||||
rt = t.__dict__.copy()
|
||||
del rt['_sa_instance_state']
|
||||
return rt
|
||||
|
|
|
@ -380,6 +380,8 @@ type Author {
|
|||
name: String!
|
||||
userpic: String
|
||||
caption: String # only for full shout
|
||||
bio: strings
|
||||
links: [String]
|
||||
}
|
||||
|
||||
# is publication
|
||||
|
|
Loading…
Reference in New Issue
Block a user