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