WeblateOrg / WeblateOrg/weblate
Performance issues with hide completed on dashboard
- Dominant language
- Python
- Stars
- 6.1k
- Forks
- 1.4k
- Avg merge
- 9h 53m
- Merged PRs (30d)
- 395
Description
### Describe the problem
When user translations list is too long (for example when there are thousands of components within a watched project like on https://weblate.eso-spolszczenie.eu/projects/eso-spolszczenie/), hiding completed translations takes seconds:

The problematic code is here:
https://github.com/WeblateOrg/weblate/blob/e39c9e8e988905d0c2083777feeb51e1f128d3df/weblate/trans/views/dashboard.py#L241-L255
The `prefetch_stats` causes the complete queryset to materialize, which fetches thousands of translations and components from the database. The queries are fast to perform, but parsing results takes 2 seconds in this particular case. We throw away most of these results later because we paginate the results in the end when rendering the template.
### Describe the solution you'd like
`get_untranslated` could lazily prefetch stats for chunks of the queryset as it goes through the queryset
### Describe alternatives you've considered
Other options might be:
* Incorporating is translated flag in the database so that this filter can be done there instead of doing that in Python
* Dropping support for hiding completed translations on the dashboard, it was originally requested in #677
### Screenshots
_No response_
### Additional context
@tomkolp This is why the dashboard on your instance is slow for most of the users.
Contributor guide
Assessment
This issue has not been assessed yet.