|
7 | 7 |
|
8 | 8 | from django.contrib.postgres.fields import ArrayField |
9 | 9 | from django.db import models |
10 | | -from django.db.models import Count, F, Prefetch, Q |
| 10 | +from django.db.models import F, Prefetch, Q |
11 | 11 | from django.utils import timezone |
12 | 12 |
|
13 | 13 | from pontoon.base import utils |
@@ -283,56 +283,6 @@ class Meta: |
283 | 283 | def __str__(self): |
284 | 284 | return self.string |
285 | 285 |
|
286 | | - def get_stats(self, locale) -> dict[str, int]: |
287 | | - """ |
288 | | - Get stats for a single (entity, locale) pair. |
289 | | -
|
290 | | - :arg Locale locale: filter translations for this locale. |
291 | | - :return: a dictionary with stats for the Entity+Locale |
292 | | - """ |
293 | | - stats = self.translation_set.filter(locale=locale).aggregate( |
294 | | - approved_count=Count( |
295 | | - "pk", |
296 | | - filter=Q(approved=True, errors__isnull=True, warnings__isnull=True), |
297 | | - ), |
298 | | - pretranslated_count=Count( |
299 | | - "pk", |
300 | | - filter=Q( |
301 | | - pretranslated=True, errors__isnull=True, warnings__isnull=True |
302 | | - ), |
303 | | - ), |
304 | | - errors_count=Count( |
305 | | - "pk", |
306 | | - distinct=True, |
307 | | - filter=Q( |
308 | | - Q(Q(approved=True) | Q(pretranslated=True) | Q(fuzzy=True)) |
309 | | - & Q(errors__isnull=False) |
310 | | - ), |
311 | | - ), |
312 | | - warnings_count=Count( |
313 | | - "pk", |
314 | | - distinct=True, |
315 | | - filter=Q( |
316 | | - Q(Q(approved=True) | Q(pretranslated=True) | Q(fuzzy=True)) |
317 | | - & Q(warnings__isnull=False) |
318 | | - ), |
319 | | - ), |
320 | | - unreviewed_count=Count( |
321 | | - "pk", |
322 | | - distinct=True, |
323 | | - filter=Q( |
324 | | - approved=False, rejected=False, pretranslated=False, fuzzy=False |
325 | | - ), |
326 | | - ), |
327 | | - ) |
328 | | - return { |
329 | | - "approved": stats["approved_count"], |
330 | | - "pretranslated": stats["pretranslated_count"], |
331 | | - "errors": stats["errors_count"], |
332 | | - "warnings": stats["warnings_count"], |
333 | | - "unreviewed": stats["unreviewed_count"], |
334 | | - } |
335 | | - |
336 | 286 | def has_changed(self, locale): |
337 | 287 | """ |
338 | 288 | Check if translations in the given locale have changed since the |
|
0 commit comments