From 616463e3da0cba6900415cfb216d6ba12ee68e18 Mon Sep 17 00:00:00 2001 From: tonyrewin Date: Mon, 5 Sep 2022 05:09:44 +0300 Subject: [PATCH] some migration fix --- migration/tables/content_items.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/migration/tables/content_items.py b/migration/tables/content_items.py index 78d37a39..764d2fbf 100644 --- a/migration/tables/content_items.py +++ b/migration/tables/content_items.py @@ -72,7 +72,7 @@ async def migrate(entry, storage): } else: userdata = User.default_user.dict() - assert userdata, "no user found for %s from " % [oid, len(users_by_oid.keys())] + assert userdata, "no user found for %s from %d" % [oid, len(users_by_oid.keys())] r["authors"] = [ userdata, ] @@ -220,7 +220,7 @@ async def migrate(entry, storage): ShoutTopic.create( **{"shout": shout_dict["slug"], "topic": newslug} ) - except: + except Exception: print("[migration] shout topic error: " + newslug) session.commit() if newslug not in shout_dict["topics"]: @@ -269,15 +269,14 @@ async def migrate(entry, storage): ) reaction.update(reaction_dict) else: - day = (reaction_dict.get("createdAt") or ts).replace( + reaction_dict['day'] = (reaction_dict.get("createdAt") or ts).replace( hour=0, minute=0, second=0, microsecond=0 ) rea = Reaction.create(**reaction_dict) await ReactedStorage.increment(rea) # shout_dict['ratings'].append(reaction_dict) - except: - print("[migration] content_item.ratings error: \n%r" % content_rating) - raise Exception + except Exception: + raise Exception("[migration] content_item.ratings error: \n%r" % content_rating) # shout views ViewedByDay.create(shout=shout_dict["slug"], value=entry.get("views", 1))