Skip to content

Commit

Permalink
Fix total conversation count when paginated
Browse files Browse the repository at this point in the history
Previously the total conversation count still was only the number of
conversations on the displayed page. Change the total_conversation_count
to actually have all of the filtered conversations (not just the ones
on the page.)
Fixup commit to cf39a47.
Fixes #94
  • Loading branch information
etanttila committed Jul 22, 2024
1 parent 25ada3b commit 20bc1b4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions feedback/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,6 @@ def get_conversation_dict(conv: Conversation, fbs: List[Feedback]) -> Dict:
return conv_dict

context['conversations'] = [get_conversation_dict(c, fbs) for c, fbs in convs.items()]
context['total_conversation_count'] = len(context['conversations'])


class PaginatedMixin():
Expand All @@ -566,11 +565,13 @@ def get_paginate_by(self, queryset): # pylint: disable=unused-argument
self.paginate_by = int(value)
return self.paginate_by

def get_context_data(self, **kwargs):
def get_context_data(self, **kwargs) -> dict:
context = super().get_context_data(**kwargs)
context['page_sizes'] = list(map(
lambda size: (size, int(size) == self.paginate_by),
self.PAGE_SIZE_CHOICES))
feedbacks = context['paginator'].object_list
context['total_conversation_count'] = len({f.conversation.id for f in feedbacks})
return context


Expand Down

0 comments on commit 20bc1b4

Please sign in to comment.