Self hosted FLOSS fitness/workout, nutrition and weight tracker
Prettify the output of the statistics calculation
Roland Geider290faf0a80b3
diff --git a/wger/trophies/management/commands/recalculate_statistics.py b/wger/trophies/management/commands/recalculate_statistics.pyindex 4da4af6cc..1e701a45e 100644--- a/wger/trophies/management/commands/recalculate_statistics.py+++ b/wger/trophies/management/commands/recalculate_statistics.py@@ -26,6 +26,9 @@ from django.core.management.base import ()from django.utils import timezone+# Third Party+from tqdm import tqdm+# wgerfrom wger.trophies.services.statistics import UserStatisticsService@@ -128,22 +131,23 @@ class Command(BaseCommand):processed = 0errors = 0- for user in users:- try:- UserStatisticsService.update_statistics(user)- processed += 1-- if verbosity >= 2:- self.stdout.write(self.style.SUCCESS(f'✓ Processed: {user.username}'))- elif verbosity >= 1 and processed % 100 == 0:- self.stdout.write(f' Processed {processed}/{total_users} users...')-- except Exception as e:- errors += 1- if verbosity >= 1:- self.stdout.write(- self.style.ERROR(f'✗ Error processing {user.username}: {str(e)}')- )+ with tqdm(total=total_users, unit='B', unit_scale=True) as pbar:+ for user in users:+ try:+ UserStatisticsService.update_statistics(user)+ processed += 1++ if verbosity >= 2:+ self.stdout.write(self.style.SUCCESS(f'✓ Processed: {user.username}'))+ elif verbosity >= 1:+ pbar.update(1)++ except Exception as e:+ errors += 1+ if verbosity >= 1:+ self.stdout.write(+ self.style.ERROR(f'✗ Error processing {user.username}: {str(e)}')+ )if verbosity >= 1:self.stdout.write(