mirror of
https://github.com/minetest/contentdb.git
synced 2024-11-10 01:23:48 +01:00
Improve user comments page performance
This commit is contained in:
parent
315337d552
commit
43af3a8e75
@ -397,13 +397,11 @@ def user_comments(username):
|
||||
|
||||
# Filter replies the current user can see
|
||||
query = ThreadReply.query.options(selectinload(ThreadReply.thread)).filter_by(author=user)
|
||||
only_public = False
|
||||
if current_user != user and not (current_user.is_authenticated and current_user.rank.at_least(UserRank.APPROVER)):
|
||||
if user.username == "ContentDB" or not current_user.is_authenticated:
|
||||
# The ContentDB user simply has too many comments, don't bother checking more than thread privacy
|
||||
query = query.filter(ThreadReply.thread.has(private=False))
|
||||
else:
|
||||
query = query.filter(or_(ThreadReply.thread.has(private=False), Thread.watchers.contains(current_user)))
|
||||
query = query.filter(ThreadReply.thread.has(private=False))
|
||||
only_public = True
|
||||
|
||||
pagination = query.order_by(db.desc(ThreadReply.created_at)).paginate(page=page, per_page=num)
|
||||
|
||||
return render_template("threads/user_comments.html", user=user, pagination=pagination)
|
||||
return render_template("threads/user_comments.html", user=user, pagination=pagination, only_public=only_public)
|
||||
|
@ -67,6 +67,12 @@
|
||||
</ul>
|
||||
|
||||
{{ render_pagination(pagination, url_set_query) }}
|
||||
|
||||
{% if only_public %}
|
||||
<p class="mt-5 text-muted">
|
||||
{{ _("Only showing replies to public threads") }}
|
||||
</p>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<p>
|
||||
<i>
|
||||
|
Loading…
Reference in New Issue
Block a user