mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
more efficient subscribers query, using a join #131
This commit is contained in:
parent
588133fda6
commit
ff7f89bfce
1 changed files with 3 additions and 5 deletions
|
@ -955,15 +955,13 @@ def community_moderate_subscribers(actor):
|
|||
if community is not None:
|
||||
if community.is_moderator() or current_user.is_admin():
|
||||
|
||||
#TODO - not sure if this is the most efficient query and we might want to look in to paging the results
|
||||
subscribers = CommunityMember.query.filter(CommunityMember.community_id == community.id).all()
|
||||
subscriber_user_ids = [subscriber.user_id for subscriber in subscribers]
|
||||
subscriber_list = User.query.filter(User.id.in_(subscriber_user_ids)).all()
|
||||
subscribers = User.query.join(CommunityMember, CommunityMember.user_id == User.id).filter(CommunityMember.community_id == community.id)
|
||||
subscribers = subscribers.filter(CommunityMember.is_banned == False).all()
|
||||
|
||||
banned_people = User.query.join(CommunityBan, CommunityBan.user_id == User.id).filter(CommunityBan.community_id == community.id).all()
|
||||
|
||||
return render_template('community/community_moderate_subscribers.html', title=_('Moderation of %(community)s', community=community.display_name()),
|
||||
community=community, current='subscribers', subscribers=subscriber_list, banned_people=banned_people,
|
||||
community=community, current='subscribers', subscribers=subscribers, banned_people=banned_people,
|
||||
moderating_communities=moderating_communities(current_user.get_id()),
|
||||
joined_communities=joined_communities(current_user.get_id()),
|
||||
inoculation=inoculation[randint(0, len(inoculation) - 1)]
|
||||
|
|
Loading…
Add table
Reference in a new issue