migration fixes
This commit is contained in:
parent
3358ba8b99
commit
1254b14163
|
@ -4,8 +4,7 @@ from orm import Reaction, User
|
||||||
from base.orm import local_session
|
from base.orm import local_session
|
||||||
from migration.html2text import html2text
|
from migration.html2text import html2text
|
||||||
from orm.reaction import ReactionKind
|
from orm.reaction import ReactionKind
|
||||||
from orm.shout import Shout
|
from services.stat.reacted import ReactedStorage
|
||||||
from services.stat.reacted import ReactedByDay
|
|
||||||
|
|
||||||
ts = datetime.now()
|
ts = datetime.now()
|
||||||
|
|
||||||
|
@ -73,7 +72,7 @@ def migrate(entry, storage):
|
||||||
# creating reaction from old comment
|
# creating reaction from old comment
|
||||||
day = (reaction_dict.get('createdAt') or ts).replace(hour=0, minute=0, second=0, microsecond=0)
|
day = (reaction_dict.get('createdAt') or ts).replace(hour=0, minute=0, second=0, microsecond=0)
|
||||||
reaction = Reaction.create(**reaction_dict)
|
reaction = Reaction.create(**reaction_dict)
|
||||||
ReactedByDay.create(shout=reaction.shout, reaction=reaction.id, kind=reaction.kind, day=day)
|
ReactedStorage.increment(reaction)
|
||||||
|
|
||||||
reaction_dict['id'] = reaction.id
|
reaction_dict['id'] = reaction.id
|
||||||
for comment_rating_old in entry.get('ratings',[]):
|
for comment_rating_old in entry.get('ratings',[]):
|
||||||
|
@ -90,8 +89,7 @@ def migrate(entry, storage):
|
||||||
try:
|
try:
|
||||||
# creating reaction from old rating
|
# creating reaction from old rating
|
||||||
rr = Reaction.create(**re_reaction_dict)
|
rr = Reaction.create(**re_reaction_dict)
|
||||||
day = (re_reaction_dict.get('createdAt') or ts).replace(hour=0, minute=0, second=0, microsecond=0)
|
ReactedStorage.increment(rr)
|
||||||
ReactedByDay.create(shout=rr.shout, reaction=rr.id, kind=rr.kind, day=day, replyTo=reaction.id)
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('[migration] comment rating error: %r' % re_reaction_dict)
|
print('[migration] comment rating error: %r' % re_reaction_dict)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from dateutil.parser import parse as date_parse
|
from dateutil.parser import parse as date_parse
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from orm.shout import Shout, ShoutTopic, User
|
from orm.shout import Shout, ShoutTopic, User
|
||||||
from services.stat.reacted import ReactedByDay
|
from services.stat.reacted import ReactedStorage
|
||||||
from services.stat.viewed import ViewedByDay
|
from services.stat.viewed import ViewedByDay
|
||||||
from transliterate import translit
|
from transliterate import translit
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
@ -162,7 +162,8 @@ def migrate(entry, storage):
|
||||||
print('[migration] something went wrong with shout: \n%r' % shout_dict)
|
print('[migration] something went wrong with shout: \n%r' % shout_dict)
|
||||||
raise e
|
raise e
|
||||||
session.commit()
|
session.commit()
|
||||||
except:
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
print(s)
|
print(s)
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
|
@ -217,7 +218,7 @@ def migrate(entry, storage):
|
||||||
else:
|
else:
|
||||||
day = (reaction_dict.get('createdAt') or ts).replace(hour=0, minute=0, second=0, microsecond=0)
|
day = (reaction_dict.get('createdAt') or ts).replace(hour=0, minute=0, second=0, microsecond=0)
|
||||||
rea = Reaction.create(**reaction_dict)
|
rea = Reaction.create(**reaction_dict)
|
||||||
ReactedByDay.create(shout=rea.shout, reaction=rea.id, kind=rea.kind, day=day)
|
ReactedStorage.increment(rea)
|
||||||
# shout_dict['ratings'].append(reaction_dict)
|
# shout_dict['ratings'].append(reaction_dict)
|
||||||
except:
|
except:
|
||||||
print('[migration] content_item.ratings error: \n%r' % content_rating)
|
print('[migration] content_item.ratings error: \n%r' % content_rating)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user