From 42091c427aba10ea4e73e911ea7f8b614e5e63d2 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 26 Feb 2022 18:00:49 +0200 Subject: [PATCH] flush --- files/routes/admin.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/files/routes/admin.py b/files/routes/admin.py index f3186b277..14dc51f5c 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -64,14 +64,17 @@ def merge(v, id1, id2): if not user1.has_badge(badge.badge_id): badge.user_id = user1.id g.db.add(badge) + g.db.flush() for mod in mods: if not user1.mods(mod.sub): mod.user_id = user1.id g.db.add(mod) + g.db.flush() for exile in exiles: if not user1.exiled_from(exile.sub): exile.user_id = user1.id g.db.add(exile) + g.db.flush() for kind in ('comment_count', 'post_count', 'winnings', 'received_award_count', 'coins_spent', 'lootboxes_bought', 'coins', 'truecoins', 'procoins', 'subs_created'): amount = getattr(user1, kind) + getattr(user2, kind) @@ -118,11 +121,12 @@ def merge_all(v, id): g.db.add(thing) - things = g.db.query(Badge).filter(Badge.user_id.in_(alt_ids)).all() - for badge in things: + badges = g.db.query(Badge).filter(Badge.user_id.in_(alt_ids)).all() + for badge in badges: if not user.has_badge(badge.badge_id): badge.user_id = user.id g.db.add(badge) + g.db.flush() for alt in user.alts_unique: for kind in ('comment_count', 'post_count', 'winnings', 'received_award_count', 'coins_spent', 'lootboxes_bought', 'coins', 'truecoins', 'procoins', 'subs_created'):