remove unnecessary flushes

pull/173/head
Aevann 2023-07-25 23:35:54 +03:00
parent 333e1329f9
commit a94dda90dd
12 changed files with 2 additions and 23 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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()

View File

@ -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)

View File

@ -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,

View File

@ -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)

View File

@ -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",

View File

@ -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

View File

@ -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")

View File

@ -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)

View File

@ -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)