forked from MarseyWorld/MarseyWorld
Refactor /comments to use single query.
parent
ed27225d10
commit
2edeb48751
|
@ -213,22 +213,22 @@ def all_comments(v):
|
||||||
return render_template("home_comments.html", v=v, sort=sort, t=t, page=page, comments=comments, standalone=True, next_exists=next_exists)
|
return render_template("home_comments.html", v=v, sort=sort, t=t, page=page, comments=comments, standalone=True, next_exists=next_exists)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@cache.memoize(timeout=86400)
|
@cache.memoize(timeout=86400)
|
||||||
def comment_idlist(page=1, v=None, nsfw=False, sort="new", t="all", gt=0, lt=0, site=None):
|
def comment_idlist(v=None, page=1, sort="new", t="all", gt=0, lt=0, site=None):
|
||||||
|
comments = g.db.query(Comment.id) \
|
||||||
comments = g.db.query(Comment.id).filter(Comment.parent_submission != None, Comment.author_id.notin_(v.userblocks))
|
.join(Comment.post) \
|
||||||
|
.filter(Comment.parent_submission != None)
|
||||||
|
|
||||||
if v.admin_level < PERMS['POST_COMMENT_MODERATION']:
|
if v.admin_level < PERMS['POST_COMMENT_MODERATION']:
|
||||||
private = [x[0] for x in g.db.query(Submission.id).filter(Submission.private == True).all()]
|
comments = comments.filter(
|
||||||
|
Comment.is_banned == False,
|
||||||
comments = comments.filter(Comment.is_banned==False, Comment.deleted_utc == 0, Comment.parent_submission.notin_(private))
|
Comment.deleted_utc == 0,
|
||||||
|
Submission.private == False,
|
||||||
|
Comment.author_id.notin_(v.userblocks),
|
||||||
|
)
|
||||||
|
|
||||||
if not v.paid_dues:
|
if not v.paid_dues:
|
||||||
club = [x[0] for x in g.db.query(Submission.id).filter(Submission.club == True).all()]
|
comments = comments.filter(Submission.club == False)
|
||||||
comments = comments.filter(Comment.parent_submission.notin_(club))
|
|
||||||
|
|
||||||
|
|
||||||
if gt: comments = comments.filter(Comment.created_utc > gt)
|
if gt: comments = comments.filter(Comment.created_utc > gt)
|
||||||
if lt: comments = comments.filter(Comment.created_utc < lt)
|
if lt: comments = comments.filter(Comment.created_utc < lt)
|
||||||
|
|
Loading…
Reference in New Issue