forked from rDrama/rDrama
master
parent
e925b918f4
commit
6b30d8b1ea
|
@ -86,7 +86,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None):
|
||||||
blocked = v.blocked.subquery()
|
blocked = v.blocked.subquery()
|
||||||
|
|
||||||
|
|
||||||
comms = g.db.query(
|
comments = g.db.query(
|
||||||
Comment,
|
Comment,
|
||||||
blocking.c.id,
|
blocking.c.id,
|
||||||
blocked.c.id,
|
blocked.c.id,
|
||||||
|
@ -107,13 +107,13 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None):
|
||||||
elif sort == "bottom":
|
elif sort == "bottom":
|
||||||
comments = sorted(comments.all(), key=lambda x: x.score)
|
comments = sorted(comments.all(), key=lambda x: x.score)
|
||||||
elif sort == "new":
|
elif sort == "new":
|
||||||
comments = comms.order_by(Comment.created_utc.desc()).all()
|
comments = comments.order_by(Comment.created_utc.desc()).all()
|
||||||
elif sort == "old":
|
elif sort == "old":
|
||||||
comments = comms.order_by(Comment.created_utc.asc()).all()
|
comments = comments.order_by(Comment.created_utc.asc()).all()
|
||||||
elif sort == "controversial":
|
elif sort == "controversial":
|
||||||
comments = sorted(comms.all(), key=lambda x: x.score_disputed, reverse=True)
|
comments = sorted(comments.all(), key=lambda x: x.score_disputed, reverse=True)
|
||||||
elif sort == "random":
|
elif sort == "random":
|
||||||
c = comms.all()
|
c = comments.all()
|
||||||
comments = random.sample(c, k=len(c))
|
comments = random.sample(c, k=len(c))
|
||||||
else:
|
else:
|
||||||
abort(422)
|
abort(422)
|
||||||
|
@ -126,24 +126,24 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None):
|
||||||
output.append(comment)
|
output.append(comment)
|
||||||
else:
|
else:
|
||||||
|
|
||||||
comms = g.db.query(
|
comments = g.db.query(
|
||||||
Comment
|
Comment
|
||||||
).filter(
|
).filter(
|
||||||
Comment.parent_comment_id.in_(current_ids)
|
Comment.parent_comment_id.in_(current_ids)
|
||||||
)
|
)
|
||||||
|
|
||||||
if sort == "top":
|
if sort == "top":
|
||||||
output = sorted(comms.all(), key=lambda x: x.score, reverse=True)
|
output = sorted(comments.all(), key=lambda x: x.score, reverse=True)
|
||||||
elif sort == "bottom":
|
elif sort == "bottom":
|
||||||
output = sorted(comms.all(), key=lambda x: x.score)
|
output = sorted(comments.all(), key=lambda x: x.score)
|
||||||
elif sort == "new":
|
elif sort == "new":
|
||||||
output = comms.order_by(Comment.created_utc.desc()).all()
|
output = comments.order_by(Comment.created_utc.desc()).all()
|
||||||
elif sort == "old":
|
elif sort == "old":
|
||||||
output = comms.order_by(Comment.created_utc.asc()).all()
|
output = comments.order_by(Comment.created_utc.asc()).all()
|
||||||
elif sort == "controversial":
|
elif sort == "controversial":
|
||||||
output = sorted(comms.all(), key=lambda x: x.score_disputed, reverse=True)
|
output = sorted(comments.all(), key=lambda x: x.score_disputed, reverse=True)
|
||||||
elif sort == "random":
|
elif sort == "random":
|
||||||
c = comms.all()
|
c = comments.all()
|
||||||
output = random.sample(c, k=len(c))
|
output = random.sample(c, k=len(c))
|
||||||
else:
|
else:
|
||||||
abort(422)
|
abort(422)
|
||||||
|
|
Loading…
Reference in New Issue