]> git.ozlabs.org Git - patchwork/blobdiff - patchwork/management/commands/retag.py
Add patch tag infrastructure
[patchwork] / patchwork / management / commands / retag.py
diff --git a/patchwork/management/commands/retag.py b/patchwork/management/commands/retag.py
new file mode 100644 (file)
index 0000000..e07594a
--- /dev/null
@@ -0,0 +1,26 @@
+
+from django.core.management.base import BaseCommand, CommandError
+from patchwork.models import Patch
+import sys
+
+class Command(BaseCommand):
+    help = 'Update the tag (Ack/Review/Test) counts on existing patches'
+    args = '[<patch_id>...]'
+
+    def handle(self, *args, **options):
+
+        qs = Patch.objects
+
+        if args:
+            qs = qs.filter(id__in = args)
+
+        count = qs.count()
+        i = 0
+
+        for patch in qs.iterator():
+            patch.refresh_tag_counts()
+            i += 1
+            if (i % 10) == 0 or i == count:
+                sys.stdout.write('%06d/%06d\r' % (i, count))
+                sys.stdout.flush()
+        sys.stderr.write('\ndone\n')