diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index e99f7b502..ccc24c058 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -61,8 +61,6 @@ def notif_comment(text): text_html = sanitize(text, blackjack="notification") - g.db.flush() - existing = g.db.query(Comment.id).filter( Comment.author_id == AUTOJANNY_ID, Comment.parent_post == None, @@ -78,8 +76,6 @@ def notif_comment(text): n.comment_id = replace_with g.db.add(n) - g.db.flush() - for c in g.db.query(Comment).filter(Comment.id.in_(replaced)).all(): g.db.delete(c) diff --git a/files/helpers/cron.py b/files/helpers/cron.py index ce3bf8ad0..31469f513 100644 --- a/files/helpers/cron.py +++ b/files/helpers/cron.py @@ -117,7 +117,6 @@ def _sub_inactive_purge_task(): for x in to_delete: g.db.delete(x) - g.db.flush() for x in dead_holes: g.db.delete(x) diff --git a/files/routes/admin.py b/files/routes/admin.py index 7a487231a..48483dcd1 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -696,7 +696,6 @@ def admin_add_alt(v:User, username): is_manual=True, ) g.db.add(a) - g.db.flush() cache.delete_memoized(get_alt_graph_ids, user1.id) cache.delete_memoized(get_alt_graph_ids, user2.id) diff --git a/files/routes/asset_submissions.py b/files/routes/asset_submissions.py index 0b62a4c45..2c9608ea1 100644 --- a/files/routes/asset_submissions.py +++ b/files/routes/asset_submissions.py @@ -361,8 +361,6 @@ def approve_hat(v, name): hat.description = description g.db.add(hat) - - g.db.flush() author = hat.author all_by_author = g.db.query(HatDef).filter_by(author_id=author.id).count() diff --git a/files/routes/awards.py b/files/routes/awards.py index d720ceadf..289181470 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -108,7 +108,6 @@ def buy(v:User, award): lootbox_items.append(AWARDS[lb_award]['title']) lb_award = AwardRelationship(user_id=v.id, kind=lb_award, price_paid=price // LOOTBOX_ITEM_COUNT) g.db.add(lb_award) - g.db.flush() v.lootboxes_bought += 1 lootbox_msg = "You open your lootbox and receive: " + ', '.join(lootbox_items) diff --git a/files/routes/groups.py b/files/routes/groups.py index ff810c6aa..1b0ad32b7 100644 --- a/files/routes/groups.py +++ b/files/routes/groups.py @@ -43,7 +43,6 @@ def create_group(v): group = Group(name=name) g.db.add(group) - g.db.flush() group_membership = GroupMembership( user_id=v.id, diff --git a/files/routes/login.py b/files/routes/login.py index 4db9c7c01..270936904 100644 --- a/files/routes/login.py +++ b/files/routes/login.py @@ -321,8 +321,6 @@ def sign_up_post(v:Optional[User]): g.db.add(new_user) - g.db.flush() - if ref_id: ref_user = get_account(ref_id) diff --git a/files/routes/notifications.py b/files/routes/notifications.py index 837f8fbb9..5d0fffc87 100644 --- a/files/routes/notifications.py +++ b/files/routes/notifications.py @@ -68,8 +68,6 @@ def notifications_modmail(v): total = comments.count() listing = comments.order_by(Comment.id.desc()).offset(PAGE_SIZE*(page-1)).limit(PAGE_SIZE).all() - g.db.flush() - if v.client: return {"data":[x.json for x in listing]} return render_template("notifications.html", @@ -411,8 +409,6 @@ def notifications(v:User): all_cids = set(all_cids) output = get_comments_v_properties(v, None, Comment.id.in_(all_cids))[1] - g.db.flush() - if v.client: return {"data":[x.json for x in listing]} return render_template("notifications.html", diff --git a/files/routes/routehelpers.py b/files/routes/routehelpers.py index fb1bd4686..00333f0ef 100644 --- a/files/routes/routehelpers.py +++ b/files/routes/routehelpers.py @@ -52,7 +52,6 @@ def add_alt(user1:int, user2:int): if not existing: new_alt = Alt(user1=user1, user2=user2) g.db.add(new_alt) - g.db.flush() cache.delete_memoized(get_alt_graph_ids, user1) cache.delete_memoized(get_alt_graph_ids, user2) @@ -80,7 +79,7 @@ def check_for_alts(current:User, include_current_session=False): past_accs.add(current_id) if include_current_session: session["history"] = list(past_accs) - g.db.flush() + for u in get_alt_graph(current.id): if u.shadowbanned and not current.shadowbanned: current.shadowbanned = u.shadowbanned diff --git a/files/routes/settings.py b/files/routes/settings.py index 85a9dc9bc..8f19da616 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -530,7 +530,6 @@ def settings_security_post(v): v.mfa_secret = None g.db.add(v) - g.db.flush() return render_template("settings/security.html", v=v, msg="Two-factor authentication disabled!") @app.post("/settings/log_out_all_others") diff --git a/files/routes/subs.py b/files/routes/subs.py index 87b81dfdc..4635b9d83 100644 --- a/files/routes/subs.py +++ b/files/routes/subs.py @@ -388,7 +388,6 @@ def create_sub2(v): sub = Sub(name=name) g.db.add(sub) - g.db.flush() mod = Mod(user_id=v.id, sub=sub.name) g.db.add(mod) diff --git a/files/routes/votes.py b/files/routes/votes.py index e58a307f1..071f6cfe5 100644 --- a/files/routes/votes.py +++ b/files/routes/votes.py @@ -111,11 +111,9 @@ def vote_post_comment(target_id, new, v, cls, vote_cls): else: return 0 - try: g.db.flush() + try: return votes.count() except: abort(500) - return votes.count() - target.upvotes = get_vote_count(1, False) target.downvotes = get_vote_count(-1, False)