##// END OF EJS Templates
Updated version. Use "neboard dev" label for the development version of site
Updated version. Use "neboard dev" label for the development version of site

File last commit:

r1118:01343b9e default
r1222:604935b9 2.8.3 default
Show More
cleantags.py
19 lines | 535 B | text/x-python | PythonLexer
from django.core.management import BaseCommand
from django.db import transaction
from django.db.models import Count
from boards.models import Tag
__author__ = 'neko259'
class Command(BaseCommand):
help = 'Removed tags that have no threads'
@transaction.atomic
def handle(self, *args, **options):
empty = Tag.objects.annotate(num_threads=Count('thread'))\
.filter(num_threads=0).order_by('-required', 'name')
print('Removing {} empty tags'.format(empty.count()))
empty.delete()