vsd
This commit is contained in:
parent
1e94fd24be
commit
66cf9c3799
1 changed files with 54 additions and 40 deletions
|
@ -481,8 +481,43 @@ def random_post(v):
|
||||||
post = x.offset(n).limit(1).one_or_none()
|
post = x.offset(n).limit(1).one_or_none()
|
||||||
return redirect(f"{SITE_FULL}/post/{post.id}")
|
return redirect(f"{SITE_FULL}/post/{post.id}")
|
||||||
|
|
||||||
|
@app.get("/comments")
|
||||||
|
@auth_required
|
||||||
|
def all_comments(v):
|
||||||
|
|
||||||
|
|
||||||
|
page = int(request.values.get("page", 1))
|
||||||
|
|
||||||
|
sort=request.values.get("sort", "new")
|
||||||
|
t=request.values.get("t", defaulttimefilter)
|
||||||
|
|
||||||
|
try: gt=int(request.values.get("utc_greater_than", 0))
|
||||||
|
except: gt=0
|
||||||
|
|
||||||
|
try: lt=int(request.values.get("utc_less_than", 0))
|
||||||
|
except: lt=0
|
||||||
|
|
||||||
|
idlist = comment_idlist(v=v,
|
||||||
|
page=page,
|
||||||
|
sort=sort,
|
||||||
|
t=t,
|
||||||
|
gt=gt,
|
||||||
|
lt=lt
|
||||||
|
)
|
||||||
|
|
||||||
|
comments = get_comments(idlist, v=v)
|
||||||
|
|
||||||
|
next_exists = len(idlist) > 25
|
||||||
|
|
||||||
|
idlist = idlist[:25]
|
||||||
|
|
||||||
|
if request.headers.get("Authorization"): return {"data": [x.json for x in comments]}
|
||||||
|
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"):
|
def comment_idlist(page=1, v=None, nsfw=False, sort="new", t="all", gt=0, lt=0):
|
||||||
|
|
||||||
comments = g.db.query(Comment.id).filter(Comment.parent_submission != None)
|
comments = g.db.query(Comment.id).filter(Comment.parent_submission != None)
|
||||||
|
|
||||||
|
@ -497,6 +532,10 @@ def comment_idlist(page=1, v=None, nsfw=False, sort="new", t="all"):
|
||||||
comments = comments.filter(Comment.parent_submission.notin_(club))
|
comments = comments.filter(Comment.parent_submission.notin_(club))
|
||||||
|
|
||||||
|
|
||||||
|
if gt: comments = comments.filter(Comment.created_utc > gt)
|
||||||
|
if lt: comments = comments.filter(Comment.created_utc < lt)
|
||||||
|
|
||||||
|
if not gt and not lt:
|
||||||
now = int(time.time())
|
now = int(time.time())
|
||||||
if t == 'hour':
|
if t == 'hour':
|
||||||
cutoff = now - 3600
|
cutoff = now - 3600
|
||||||
|
@ -526,31 +565,6 @@ def comment_idlist(page=1, v=None, nsfw=False, sort="new", t="all"):
|
||||||
comments = comments.offset(25 * (page - 1)).limit(26).all()
|
comments = comments.offset(25 * (page - 1)).limit(26).all()
|
||||||
return [x[0] for x in comments]
|
return [x[0] for x in comments]
|
||||||
|
|
||||||
@app.get("/comments")
|
|
||||||
@auth_required
|
|
||||||
def all_comments(v):
|
|
||||||
|
|
||||||
|
|
||||||
page = int(request.values.get("page", 1))
|
|
||||||
|
|
||||||
sort=request.values.get("sort", "new")
|
|
||||||
t=request.values.get("t", defaulttimefilter)
|
|
||||||
|
|
||||||
idlist = comment_idlist(v=v,
|
|
||||||
page=page,
|
|
||||||
sort=sort,
|
|
||||||
t=t,
|
|
||||||
)
|
|
||||||
|
|
||||||
comments = get_comments(idlist, v=v)
|
|
||||||
|
|
||||||
next_exists = len(idlist) > 25
|
|
||||||
|
|
||||||
idlist = idlist[:25]
|
|
||||||
|
|
||||||
if request.headers.get("Authorization"): return {"data": [x.json for x in comments]}
|
|
||||||
return render_template("home_comments.html", v=v, sort=sort, t=t, page=page, comments=comments, standalone=True, next_exists=next_exists)
|
|
||||||
|
|
||||||
|
|
||||||
@app.get("/transfers")
|
@app.get("/transfers")
|
||||||
@auth_required
|
@auth_required
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue