Skip to content

Fix planned maintenance filter dropdown#1960

Open
aleksfl wants to merge 6 commits into
mainfrom
planned-maintenance-filter-breaks-when-selecting-filter
Open

Fix planned maintenance filter dropdown#1960
aleksfl wants to merge 6 commits into
mainfrom
planned-maintenance-filter-breaks-when-selecting-filter

Conversation

@aleksfl

@aleksfl aleksfl commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Scope and purpose

Fixes #1958.

Important note: This also changes the behaviour of the sources dropdown in the main filter menu so that selected filters stay in the dropdown even when a different search term is entered. This ensures both dropdowns behave consistently.

Contributor Checklist

Every pull request should have this checklist filled out, no matter how small it is.
More information about contributing to Argus can be found in the
Development docs.

  • Added a changelog fragment for towncrier
  • Added/amended tests for new/changed code
  • Linted/formatted the code with ruff and djLint, easiest by using pre-commit
  • The first line of the commit message continues the sentence "If applied, this commit will ...", starts with a capital letter, does not end with punctuation and is 50 characters or less long. See our how-to

@aleksfl aleksfl requested review from a team and johannaengland June 18, 2026 10:26
@aleksfl aleksfl self-assigned this Jun 18, 2026
@aleksfl aleksfl added bug Something is not working as expected planned maintenance labels Jun 18, 2026
@aleksfl aleksfl linked an issue Jun 18, 2026 that may be closed by this pull request
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown

Test results

    8 files  1 760 suites   3m 16s ⏱️
  976 tests   975 ✅ 1 💤 0 ❌
7 808 runs  7 800 ✅ 8 💤 0 ❌

Results for commit c195a69.

♻️ This comment has been updated with latest results.

@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.82%. Comparing base (19fa02e) to head (c195a69).
⚠️ Report is 41 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1960      +/-   ##
==========================================
+ Coverage   88.52%   88.82%   +0.30%     
==========================================
  Files         148      152       +4     
  Lines        7135     7276     +141     
==========================================
+ Hits         6316     6463     +147     
+ Misses        819      813       -6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@johannaengland johannaengland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The search does not work correctly - instead of replacing the choices shown with the ones fitting the search the search results are added to the list

@aleksfl aleksfl force-pushed the planned-maintenance-filter-breaks-when-selecting-filter branch from b7bbb9a to feb2653 Compare June 22, 2026 16:22
@aleksfl aleksfl requested a review from johannaengland June 22, 2026 16:24
@aleksfl

aleksfl commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

The search does not work correctly - instead of replacing the choices shown with the ones fitting the search the search results are added to the list

Heh, assumed that was intended behaviour. I have pushed a fix now.

@aleksfl aleksfl force-pushed the planned-maintenance-filter-breaks-when-selecting-filter branch 4 times, most recently from 80d7453 to e50ff7f Compare June 23, 2026 12:21
@aleksfl aleksfl requested a review from a team June 23, 2026 12:24
@aleksfl aleksfl force-pushed the planned-maintenance-filter-breaks-when-selecting-filter branch from e50ff7f to 4ac3067 Compare June 23, 2026 12:30

@lunkwill42 lunkwill42 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly ok, but a few things needs a touch-up:

Image

This 2-character minimum does no longer seem to hold true. Searching works immediately. I guess the point of it originally was to not flood the search results with every filter on earth (in fact, it seems the original limited the number of search results to 20, while the new version has no such limit?)

Also, there is a view SearchFiltersView tied to the search-filters URL that now seems to have gone orphaned - nothing uses it. If the plan is to replace it completely, it should be removed.

@aleksfl aleksfl requested a review from lunkwill42 June 24, 2026 15:10
@aleksfl

aleksfl commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

Looks mostly ok, but a few things needs a touch-up:
Image

This 2-character minimum does no longer seem to hold true. Searching works immediately. I guess the point of it originally was to not flood the search results with every filter on earth (in fact, it seems the original limited the number of search results to 20, while the new version has no such limit?)

Also, there is a view SearchFiltersView tied to the search-filters URL that now seems to have gone orphaned - nothing uses it. If the plan is to replace it completely, it should be removed.

Fixed, re-added the search result limit since it seems reasonable to have in any case.

| Q(user__last_name__icontains=query)
)
filters = sorted(filters, key=lambda f: (f.user != request.user, f.name))[:20]
filter_ids = [fid for fid in request.GET.getlist("filters") if fid.isdigit()]

@hmpf hmpf Jun 30, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up: validate with a form. (Allows for standardized error handling/logging in case somebody do want to use this for SQL injection or something.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems reasonable, I made a follow-up issue so that can be done in isolation.

)
filters = sorted(filters, key=lambda f: (f.user != request.user, f.name))[:20]
filter_ids = [fid for fid in request.GET.getlist("filters") if fid.isdigit()]
selected_filters = Filter.objects.filter(pk__in=filter_ids).select_related("user")

@hmpf hmpf Jun 30, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous code showed the user's own filters, and sorted them on users. This does not. Why?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was probably forgotten in some iteration, I re-added the functionality in the new version and added a test for the future.

@lunkwill42

lunkwill42 commented Jun 30, 2026

Copy link
Copy Markdown
Member

i moved this to changes requested - it seems @hmpf's questions warrant a response

@aleksfl aleksfl force-pushed the planned-maintenance-filter-breaks-when-selecting-filter branch from 446ac75 to c195a69 Compare June 30, 2026 18:27
@sonarqubecloud

Copy link
Copy Markdown

@aleksfl aleksfl requested a review from hmpf June 30, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something is not working as expected planned maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Planned maintenance filter breaks when selecting filter

4 participants