Optimize friend submission page

This commit is contained in:
cuom1999 2024-06-24 20:48:31 -05:00
parent 2c3e982b7b
commit caf599b5b3
2 changed files with 10 additions and 7 deletions

View file

@ -397,12 +397,13 @@ class Profile(models.Model):
return self.get_user_css_class(self.cached_display_rank, self.cached_rating) return self.get_user_css_class(self.cached_display_rank, self.cached_rating)
def get_friends(self): # list of ids, including you def get_friends(self): # list of ids, including you
friend_obj = self.following_users.prefetch_related("users") friend_obj = self.following_users.prefetch_related("users").first()
ret = [] friend_ids = (
if friend_obj: [friend.id for friend in friend_obj.users.all()] if friend_obj else []
ret = [friend.id for friend in friend_obj[0].users.all()] )
ret.append(self.id) friend_ids.append(self.id)
return ret
return friend_ids
def can_edit_organization(self, org): def can_edit_organization(self, org):
if not self.user.is_authenticated: if not self.user.is_authenticated:

View file

@ -587,7 +587,9 @@ class AllUserSubmissions(ConditionalUserTabMixin, UserMixin, GeneralSubmissions)
return context return context
class AllFriendSubmissions(LoginRequiredMixin, GeneralSubmissions): class AllFriendSubmissions(
LoginRequiredMixin, InfinitePaginationMixin, GeneralSubmissions
):
def get_queryset(self): def get_queryset(self):
friends = self.request.profile.get_friends() friends = self.request.profile.get_friends()
return ( return (