-
Notifications
You must be signed in to change notification settings - Fork 3
feat: show count of results in search result view #751
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,7 @@ | |
| from widgets.workflow_search import ( | ||
| SearchFilters, | ||
| render_search_bar_with_redirect, | ||
| get_filtered_published_runs, | ||
| render_search_filters, | ||
| render_search_results, | ||
| ) | ||
|
|
@@ -62,14 +63,17 @@ def render(request: Request, search_filters: SearchFilters | None): | |
| ) | ||
|
|
||
| search_filters = search_filters or SearchFilters() | ||
| qs = get_filtered_published_runs(request.user, search_filters) | ||
| render_search_bar_with_redirect( | ||
| request=request, | ||
| search_filters=search_filters, | ||
| max_width="600px", | ||
| ) | ||
| with gui.div(className="mt-3"): | ||
| new_filters = render_search_filters( | ||
| current_user=request.user, search_filters=copy(search_filters) | ||
| current_user=request.user, | ||
| search_filters=copy(search_filters), | ||
| result_count=len(qs), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Misleading Result Count Shows Limited ResultsThe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Unnecessary Database Queries Waste ResourcesThe database query executes unconditionally even when |
||
| ) | ||
| if new_filters != search_filters: | ||
| # if the search bar value has changed, redirect to the new search page | ||
|
|
@@ -79,7 +83,7 @@ def render(request: Request, search_filters: SearchFilters | None): | |
|
|
||
| if search_filters: | ||
| with gui.div(className="my-4"): | ||
| render_search_results(request.user, search_filters) | ||
| render_search_results(qs, request.user, search_filters) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Duplicate Database QueriesThe database query executes twice when search filters are active: first via |
||
| return | ||
|
|
||
| for category, pages in all_home_pages_by_category.items(): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: Result count is capped at 25 instead of showing total matches.
The result count will always show at most 25 because
get_filtered_published_runsreturns a sliced queryset (qs[:25]). Whenlen(qs)is called on Line 76, it evaluates the sliced queryset and returns the number of items in the slice, not the total count of matching results.For example, if 100 workflows match the filters, the UI will incorrectly display "25 results" instead of "100 results."
To fix this, obtain the count before slicing:
Alternatively, refactor
get_filtered_published_runsto return both the count and the sliced queryset, or accept a parameter to control whether to apply the slice.Also applies to: 76-76
🤖 Prompt for AI Agents