]> git.0d.be Git - django-panik-nonstop.git/commitdiff
make compute durations print progress
authorFrédéric Péters <fpeters@0d.be>
Sun, 17 May 2020 17:26:10 +0000 (19:26 +0200)
committerFrédéric Péters <fpeters@0d.be>
Sun, 17 May 2020 17:26:10 +0000 (19:26 +0200)
nonstop/management/commands/compute_durations.py

index 7fe97b8f3c17997729b31ee7d2edab12ef888810..c7ba7a8e8cbcda80ec69bd6ec032b53dbfa7f19f 100644 (file)
@@ -25,7 +25,11 @@ class Command(BaseCommand):
             qs = qs.filter(duration__isnull=True)
         if kwargs.get('recent'):
             qs = qs.filter(creation_timestamp__gt=datetime.date.today() - datetime.timedelta(days=10))
-        for track in qs:
+        if verbosity:
+            total = qs.count()
+        for i, track in enumerate(qs):
+            if verbosity:
+                print('[%s/%s] %s' % (i, total, track))
             try:
                 file_path = track.file_path()
             except AttributeError: