Added comments-per-page config.
This commit is contained in:
parent
93400e531e
commit
9fe2ffd72e
3 changed files with 11 additions and 5 deletions
1
env
1
env
|
@ -32,6 +32,7 @@ CF_ZONE=blahblahblah
|
|||
DEBIAN_FRONTEND=noninteractive
|
||||
MENTION_LIMIT=100
|
||||
MULTIMEDIA_EMBEDDING_ENABLED=False
|
||||
RESULTS_PER_PAGE_COMMENTS=200
|
||||
|
||||
# Profiling system; uncomment to enable
|
||||
# Stores and exposes sensitive data!
|
||||
|
|
|
@ -78,6 +78,7 @@ app.config['SETTINGS'] = {}
|
|||
app.config['SQLALCHEMY_DATABASE_URI'] = app.config['DATABASE_URL']
|
||||
app.config['MENTION_LIMIT'] = int(environ.get('MENTION_LIMIT', 100))
|
||||
app.config['MULTIMEDIA_EMBEDDING_ENABLED'] = environ.get('MULTIMEDIA_EMBEDDING_ENABLED', "false").lower() == "true"
|
||||
app.config['RESULTS_PER_PAGE_COMMENTS'] = int(environ.get('RESULTS_PER_PAGE_COMMENTS',50))
|
||||
|
||||
r=redis.Redis(host=environ.get("REDIS_URL", "redis://localhost"), decode_responses=True, ssl_cert_reqs=None)
|
||||
|
||||
|
|
|
@ -230,7 +230,9 @@ def post_id(pid, anything=None, v=None, sub=None):
|
|||
offset = 0
|
||||
ids = set()
|
||||
|
||||
if post.comment_count > 60 and not request.headers.get("Authorization") and not request.values.get("all"):
|
||||
limit = app.config['RESULTS_PER_PAGE_COMMENTS']
|
||||
|
||||
if post.comment_count > limit and not request.headers.get("Authorization") and not request.values.get("all"):
|
||||
comments2 = []
|
||||
count = 0
|
||||
if post.created_utc > 1638672040:
|
||||
|
@ -238,13 +240,13 @@ def post_id(pid, anything=None, v=None, sub=None):
|
|||
comments2.append(comment)
|
||||
ids.add(comment.id)
|
||||
count += g.db.query(Comment.id).filter_by(parent_submission=post.id, top_comment_id=comment.id).count() + 1
|
||||
if count > 50: break
|
||||
if count > limit: break
|
||||
else:
|
||||
for comment in comments:
|
||||
comments2.append(comment)
|
||||
ids.add(comment.id)
|
||||
count += g.db.query(Comment.id).filter_by(parent_submission=post.id, parent_comment_id=comment.id).count() + 1
|
||||
if count > 10: break
|
||||
if count > limit: break
|
||||
|
||||
if len(comments) == len(comments2): offset = 0
|
||||
else: offset = 1
|
||||
|
@ -357,20 +359,22 @@ def viewmore(v, pid, sort, offset):
|
|||
comments = comments.all()
|
||||
comments = comments[offset:]
|
||||
|
||||
limit = app.config['RESULTS_PER_PAGE_COMMENTS']
|
||||
comments2 = []
|
||||
count = 0
|
||||
|
||||
if post.created_utc > 1638672040:
|
||||
for comment in comments:
|
||||
comments2.append(comment)
|
||||
ids.add(comment.id)
|
||||
count += g.db.query(Comment.id).filter_by(parent_submission=post.id, top_comment_id=comment.id).count() + 1
|
||||
if count > 50: break
|
||||
if count > limit: break
|
||||
else:
|
||||
for comment in comments:
|
||||
comments2.append(comment)
|
||||
ids.add(comment.id)
|
||||
count += g.db.query(Comment.id).filter_by(parent_submission=post.id, parent_comment_id=comment.id).count() + 1
|
||||
if count > 10: break
|
||||
if count > limit: break
|
||||
|
||||
if len(comments) == len(comments2): offset = 0
|
||||
else: offset += 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue