extend the fix to other endpoints (might make them faster)

master
Aevann 2024-11-12 13:09:12 +02:00
parent 1c734cceca
commit f8cfb96a98
2 changed files with 10 additions and 12 deletions

View File

@ -393,14 +393,13 @@ def comment(v):
post_target.bump_utc = c.created_utc post_target.bump_utc = c.created_utc
g.db.add(post_target) g.db.add(post_target)
g.db.flush() g.db.commit()
gevent.spawn(postprocess_comment, c.body, c.body_html, c.id)
if c.parent_post: if c.parent_post:
for sort in COMMENT_SORTS.keys(): for sort in COMMENT_SORTS.keys():
cache.delete(f'post_{c.parent_post}_{sort}') cache.delete(f'post_{c.parent_post}_{sort}')
gevent.spawn(postprocess_comment, c.body, c.body_html, c.id)
if v.client: return c.json if v.client: return c.json
return {"id": c.id, "comment": render_template("comments.html", v=v, comments=[c])} return {"id": c.id, "comment": render_template("comments.html", v=v, comments=[c])}
@ -788,8 +787,7 @@ def edit_comment(cid, v):
g.db.add(n) g.db.add(n)
push_notif({x}, f'New mention of you by @{c.author_name}', c.body, c) push_notif({x}, f'New mention of you by @{c.author_name}', c.body, c)
g.db.flush() g.db.commit()
gevent.spawn(postprocess_comment, c.body, c.body_html, c.id) gevent.spawn(postprocess_comment, c.body, c.body_html, c.id)
else: else:
stop(400, "You need to change something!") stop(400, "You need to change something!")

View File

@ -775,13 +775,6 @@ def submit_post(v, hole=None):
) )
g.db.add(ma) g.db.add(ma)
cache.delete_memoized(frontlist)
cache.delete_memoized(userpagelisting)
g.db.flush() #Necessary, do NOT remove
generate_thumb = (not p.thumburl and p.url and p.domain != SITE)
gevent.spawn(postprocess_post, p.url, p.body, p.body_html, p.id, generate_thumb, False)
if not p.draft and flag_effortpost and not (SITE_NAME == 'WPD' and v.truescore < 500) and p.can_be_effortpost: if not p.draft and flag_effortpost and not (SITE_NAME == 'WPD' and v.truescore < 500) and p.can_be_effortpost:
body = f"@{v.username} has requested that {p.textlink} be marked as an effortpost!" body = f"@{v.username} has requested that {p.textlink} be marked as an effortpost!"
@ -790,6 +783,13 @@ def submit_post(v, hole=None):
if p.draft and flag_effortpost and not (SITE_NAME == 'WPD' and v.truescore < 500): if p.draft and flag_effortpost and not (SITE_NAME == 'WPD' and v.truescore < 500):
p.effortpost = True p.effortpost = True
g.db.commit()
generate_thumb = (not p.thumburl and p.url and p.domain != SITE)
gevent.spawn(postprocess_post, p.url, p.body, p.body_html, p.id, generate_thumb, False)
cache.delete_memoized(frontlist)
cache.delete_memoized(userpagelisting)
if v.client: return p.json if v.client: return p.json
else: else:
p.voted = 1 p.voted = 1