Skip to content

Commit

Permalink
Merge pull request #435 from Asgef/bugfix/429-fix-search-by-labels
Browse files Browse the repository at this point in the history
[#429] Fix labels search
  • Loading branch information
fey authored Jun 13, 2024
2 parents 57ec712 + f20bbb7 commit b316af9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
6 changes: 4 additions & 2 deletions contributors/views/generic_list_views/issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class ListView(
queryset=ContributionLabel.objects.all(),
)

def get_queryset(self):
"""Add queryset."""
def get_queryset(self): # noqa: WPS615
"""Get the initial queryset and apply all filters."""
queryset = (
Contribution.objects.filter(type='iss').
select_related('repository', 'contributor', 'info').
Expand All @@ -48,6 +48,8 @@ def get_queryset(self):
self.contributionlabel_prefetch,
).distinct()
)
self.queryset = queryset
queryset = super().get_queryset()
self.filterset = self.filterset_class(
self.request.GET,
queryset=queryset,
Expand Down
11 changes: 6 additions & 5 deletions contributors/views/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,16 @@ def get_queryset(self): # noqa: WPS615
class ContributionLabelsMixin(object):
"""A mixin for labels."""

def get_queryset(self): # noqa: WPS615
"""Get a dataset."""
def get_queryset(self):
"""Get a dataset and apply label filters if any."""
queryset = super().get_queryset()
labels_param = self.request.GET.get('contribution_labels')
if labels_param:
labels_param = labels_param.split('.')
self.queryset = self.queryset.filter(
queryset = queryset.filter(
labels__name__lower__in=labels_param,
)
return super().get_queryset()
).distinct()
return queryset


class ContributorTotalStatMixin(object):
Expand Down

0 comments on commit b316af9

Please sign in to comment.