WeblateOrg / WeblateOrg/weblate

Performance issues with hide completed on dashboard

Open
#9,868 1 comment 0 reactions 0 assignees View on GitHub
enhancement Waiting for: Demand
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:

![image](https://github.com/WeblateOrg/weblate/assets/212189/8d5e3f55-c897-4998-8159-db7e6c47cc38)

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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.