some-upgrades
This commit is contained in:
@@ -5,6 +5,7 @@ from base.orm import local_session
|
||||
from migration.html2text import html2text
|
||||
from orm.reaction import ReactionKind
|
||||
from orm.shout import Shout
|
||||
from services.stat.reacted import ReactedByDay
|
||||
|
||||
ts = datetime.now()
|
||||
|
||||
@@ -70,7 +71,9 @@ def migrate(entry, storage):
|
||||
reaction_dict['kind'] = ReactionKind.COMMENT
|
||||
|
||||
# creating reaction from old comment
|
||||
day = (reaction_dict.get('createdAt') or ts).replace(hour=0, minute=0, second=0, microsecond=0)
|
||||
reaction = Reaction.create(**reaction_dict)
|
||||
ReactedByDay.create(shout=reaction.shout, reaction=reaction.id, kind=reaction.kind, day=day)
|
||||
|
||||
reaction_dict['id'] = reaction.id
|
||||
for comment_rating_old in entry.get('ratings',[]):
|
||||
@@ -86,7 +89,10 @@ def migrate(entry, storage):
|
||||
if cts: re_reaction_dict['createdAt'] = date_parse(cts)
|
||||
try:
|
||||
# creating reaction from old rating
|
||||
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)
|
||||
ReactedByDay.create(shout=rr.shout, reaction=rr.id, kind=rr.kind, day=day)
|
||||
|
||||
except Exception as e:
|
||||
print('[migration] comment rating error: %r' % re_reaction_dict)
|
||||
raise e
|
||||
|
Reference in New Issue
Block a user