-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Show string/word numbers on search results #11910
Show string/word numbers on search results #11910
Conversation
weblate/trans/views/search.py
Outdated
|
||
# Calculate total number of strings and words | ||
total_strings = units.paginator.count | ||
total_words = sum(unit.num_words for unit in units.object_list) |
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.
The strings number is for all strings, but words number just for the current page.
weblate/templates/search.html
Outdated
@@ -19,6 +19,7 @@ | |||
{% crispy search_form %} | |||
</form> | |||
{% if page_obj.object_list %} | |||
<div><p>{{ total_strings }} strings / {{ total_words }} words</p></div> |
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.
This needs localization.
updated total_words for all words instead of words for current page.
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.
I've updated the code, pls check
@@ -157,7 +157,7 @@ def search(request, path=None): | |||
|
|||
# Calculate total number of strings and words | |||
total_strings = units.paginator.count | |||
total_words = sum(unit.num_words for unit in units.object_list) | |||
total_words = sum(unit.num_words for unit in unit_set.all()) |
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.
This will be super slow on huge results, this needs a database aggregation.
Summary:
This pull request adds the display of total strings and words in search results. Issue: #11853
Changes Introduced: