Coverage for app/venv/lib/python3.14/site-packages/weblate/utils/management/commands/ensure_stats.py: 93%

12 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-07 07:15 +0000

1# Copyright © Michal Čihař <michal@weblate.org> 

2# 

3# SPDX-License-Identifier: GPL-3.0-or-later 

4 

5 

6from django.utils import timezone 

7 

8from weblate.metrics.models import Metric 

9from weblate.metrics.tasks import collect_metrics 

10from weblate.utils.management.base import BaseCommand 

11from weblate.utils.stats import GlobalStats 

12 

13 

14class Command(BaseCommand): 

15 help = "ensures that stats are present" 

16 

17 def handle(self, *args, **options) -> None: 

18 all_strings = GlobalStats().all 

19 self.stdout.write(f"found {all_strings} strings") 

20 if not Metric.objects.filter( 20 ↛ exitline 20 didn't return from function 'handle' because the condition on line 20 was always true

21 date=timezone.now().date(), scope=Metric.SCOPE_GLOBAL 

22 ).exists(): 

23 collect_metrics()