Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#429] Fix labels search #435

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading