flush instead of committing inside requests

master
Aevann 2023-03-15 07:19:35 +02:00
parent fe2f1293f1
commit c6a7051200
7 changed files with 12 additions and 12 deletions

View File

@ -124,7 +124,7 @@ def gambler_placed_roulette_bet(gambler, bet, which, amount, currency):
{"parent_id": parent_id, "bet": bet, "which": which})
game.active = True
db.add(game)
db.commit()
db.flush()
def get_roulette_bets_and_betters():

View File

@ -283,7 +283,7 @@ def submit_hat(v:User):
hat = HatDef(name=name, author_id=author.id, description=description, price=price, submitter_id=v.id)
db.add(hat)
db.commit()
db.flush()
if v.admin_level >= PERMS['VIEW_PENDING_SUBMITTED_HATS']: hats = db.query(HatDef).filter(HatDef.submitter_id != None)
else: hats = db.query(HatDef).filter(HatDef.submitter_id == v.id)

View File

@ -40,7 +40,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None):
if notif:
notif.read = True
db.add(notif)
db.commit()
db.flush()
if comment.parent_submission:
post = comment.parent_submission
@ -684,5 +684,5 @@ def edit_comment(cid, v):
db.add(c)
db.commit()
db.flush()
return {"body": c.body, "comment": c.realbody(v)}

View File

@ -328,7 +328,7 @@ def sign_up_post(v:Optional[User]):
db.add(new_user)
db.commit()
db.flush()
if ref_id:
ref_user = get_account(ref_id)

View File

@ -706,7 +706,7 @@ def submit_post(v:User, sub=None):
cache.delete_memoized(frontlist)
cache.delete_memoized(userpagelisting)
db.commit()
db.flush()
if v.client: return p.json
else:
p.voted = 1

View File

@ -505,7 +505,7 @@ def settings_security_post(v):
v.mfa_secret = None
db.add(v)
db.commit()
db.flush()
return render_template("settings/security.html", v=v, msg="Two-factor authentication disabled!")
@app.post("/settings/log_out_all_others")

View File

@ -817,7 +817,7 @@ def u_username_wall(v:Optional[User], username:str):
if view: view.last_view_utc = int(time.time())
else: view = ViewerRelationship(viewer_id=v.id, user_id=u.id)
db.add(view)
db.commit()
db.flush()
try: page = max(int(request.values.get("page", "1")), 1)
except: page = 1
@ -872,14 +872,14 @@ def u_username_wall_comment(v:User, username:str, cid):
if view: view.last_view_utc = int(time.time())
else: view = ViewerRelationship(viewer_id=v.id, user_id=u.id)
db.add(view)
db.commit()
db.flush()
if v and request.values.get("read"):
notif = db.query(Notification).filter_by(comment_id=cid, user_id=v.id, read=False).one_or_none()
if notif:
notif.read = True
db.add(notif)
db.commit()
db.flush()
try: context = min(int(request.values.get("context", 8)), 8)
except: context = 8
@ -926,7 +926,7 @@ def u_username(v:Optional[User], username:str):
if view: view.last_view_utc = int(time.time())
else: view = ViewerRelationship(viewer_id=v.id, user_id=u.id)
db.add(view)
db.commit()
db.flush()
sort = request.values.get("sort", "new")
@ -1003,7 +1003,7 @@ def u_username_comments(username, v=None):
if view: view.last_view_utc = int(time.time())
else: view = ViewerRelationship(viewer_id=v.id, user_id=u.id)
db.add(view)
db.commit()
db.flush()
try: page = max(int(request.values.get("page", "1")), 1)
except: page = 1