Duplicate usernames in combo-box when filtering patches by delegate

Open
#383 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
backend

Research direction

Start in patchwork/filters.py at DelegateFilter around line 458 and inspect _get_delegate_qs for the project-scoped delegate query. Verify how the form receives the current project. Done means the combo-box lists each maintainer of the selected project once and excludes maintainers of other projects.

Written by the indexing model from the issue text.

Description

bug

The combo-box with the list of delegates to filter by has duplicate usernames. It lists a maintainer more than once if he/she maintains multiple projects. It also lists maintainers of other projects who don't maintain the one I'm filtering patches in.

This happens because DelegateFilter's form doesn't filter by project:
https://github.com/getpatchwork/patchwork/blame/bdb049c7939b7cdea1eddf029a0bc47cb338da67/patchwork/filters.py#L458

        delegates = User.objects.filter(
            profile__maintainer_projects__isnull=False)

Eliminating duplicate rows by using distinct() works, but we still have the issue of different project maintainers being listed in the same list:

        delegates = User.objects.filter(
            profile__maintainer_projects__isnull=False).distinct()

Maybe we should use _get_delegate_qs instead?

Dominant language
Python
Stars
317
Forks
91
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from getpatchwork/patchwork

All issues in getpatchwork/patchwork

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.