]> git.ozlabs.org Git - patchwork/blob - patchwork/management/commands/retag.py
parsemail: Don't catch all exceptions when a Project isn't found
[patchwork] / patchwork / management / commands / retag.py
1
2 from django.core.management.base import BaseCommand, CommandError
3 from patchwork.models import Patch
4 import sys
5
6 class Command(BaseCommand):
7     help = 'Update the tag (Ack/Review/Test) counts on existing patches'
8     args = '[<patch_id>...]'
9
10     def handle(self, *args, **options):
11
12         qs = Patch.objects
13
14         if args:
15             qs = qs.filter(id__in = args)
16
17         count = qs.count()
18         i = 0
19
20         for patch in qs.iterator():
21             patch.refresh_tag_counts()
22             i += 1
23             if (i % 10) == 0 or i == count:
24                 sys.stdout.write('%06d/%06d\r' % (i, count))
25                 sys.stdout.flush()
26         sys.stderr.write('\ndone\n')