Added filter to make sure new comments only show up on page refresh
This commit is contained in:
parent
256a43527a
commit
38e263d931
1 changed files with 4 additions and 2 deletions
|
@ -283,6 +283,8 @@ def viewmore(v, pid, sort, offset):
|
||||||
try: ids = set(int(x) for x in request.values.get("ids").split(','))
|
try: ids = set(int(x) for x in request.values.get("ids").split(','))
|
||||||
except: abort(400)
|
except: abort(400)
|
||||||
|
|
||||||
|
newest = g.db.query(Comment).filter(Comment.id.in_(ids)).order_by(Comment.created_utc.desc()).first()
|
||||||
|
|
||||||
if v:
|
if v:
|
||||||
votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery()
|
votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery()
|
||||||
|
|
||||||
|
@ -328,7 +330,7 @@ def viewmore(v, pid, sort, offset):
|
||||||
comment.is_blocked = c[3] or 0
|
comment.is_blocked = c[3] or 0
|
||||||
output.append(comment)
|
output.append(comment)
|
||||||
|
|
||||||
comments = comments.filter(Comment.level == 1)
|
comments = comments.filter(Comment.level == 1).filter(Comment.created_utc < newest.created_utc)
|
||||||
|
|
||||||
if sort == "new":
|
if sort == "new":
|
||||||
comments = comments.order_by(Comment.created_utc.desc())
|
comments = comments.order_by(Comment.created_utc.desc())
|
||||||
|
@ -356,7 +358,7 @@ def viewmore(v, pid, sort, offset):
|
||||||
elif sort == "bottom":
|
elif sort == "bottom":
|
||||||
comments = comments.order_by(Comment.upvotes - Comment.downvotes)
|
comments = comments.order_by(Comment.upvotes - Comment.downvotes)
|
||||||
|
|
||||||
comments = comments.all()
|
comments = comments.filter(Comment.created_utc < newest.created_utc).all()
|
||||||
comments = comments[offset:]
|
comments = comments[offset:]
|
||||||
|
|
||||||
limit = app.config['RESULTS_PER_PAGE_COMMENTS']
|
limit = app.config['RESULTS_PER_PAGE_COMMENTS']
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue