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

Show string/word numbers on search results #11910

Closed
wants to merge 8 commits into from
Closed

Show string/word numbers on search results #11910

wants to merge 8 commits into from

Conversation

JagdishAneshwar
Copy link

@JagdishAneshwar JagdishAneshwar commented Jun 20, 2024

Summary:

This pull request adds the display of total strings and words in search results. Issue: #11853

Changes Introduced:

  • Updated the search view to calculate total_strings and total_words from the search results.
  • Modified search.html to show total_strings and total_words at the top of the search results.


# Calculate total number of strings and words
total_strings = units.paginator.count
total_words = sum(unit.num_words for unit in units.object_list)
Copy link
Member

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.

@@ -19,6 +19,7 @@
{% crispy search_form %}
</form>
{% if page_obj.object_list %}
<div><p>{{ total_strings }} strings / {{ total_words }} words</p></div>
Copy link
Member

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.
Copy link
Author

@JagdishAneshwar JagdishAneshwar left a 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())
Copy link
Member

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.

@JagdishAneshwar JagdishAneshwar closed this by deleting the head repository Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants