aftermerge, migration fixed

This commit is contained in:
2021-08-26 00:20:53 +03:00
parent 78b41cb9c4
commit 698de9114c
14 changed files with 161 additions and 96 deletions

View File

@@ -48,22 +48,31 @@ def shouts(limit):
data = json.loads(open('migration/data/content_items.json').read())
newdata = {}
print(str(len(data)) + ' entries was loaded. now migrating...')
errored = []
for entry in data:
oid = entry['_id']
newdata[oid] = migrateShout(entry)
counter += 1
author = newdata[oid]['authors'][0]['slug']
if author == 'discours':
discoursAuthor += 1
line = str(counter) + ': ' + newdata[oid]['slug'] + " @" + author
print(line)
open('./shouts.id.log','a').write(line + '\n')
if counter > limit:
break
try:
oid = entry['_id']
newdata[oid] = migrateShout(entry)
counter += 1
author = newdata[oid]['authors'][0]['slug']
if author == 'discours':
discoursAuthor += 1
line = str(counter) + ': ' + newdata[oid]['slug'] + " @" + str(author)
print(line)
open('./shouts.id.log','a').write(line + '\n')
if counter > limit:
break
except Exception:
print(entry['_id'])
errored.append(entry)
raise Exception
open('migration/data/shouts.dict.json','w').write( json.dumps(newdata, cls=DateTimeEncoder) )
print(str(counter) + ' shouts were migrated')
print(str(discoursAuthor) + ' from them by uknown users')
print(str(discoursAuthor) + ' from them by @discours')
print(str(len(errored)) + ' shouts without authors')
if __name__ == '__main__':
import sys