summaryrefslogtreecommitdiffstats
path: root/askbot/management
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-09-05 12:58:53 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-09-05 12:58:53 -0400
commit13d2492046b597633bbb6f59bfc7e765b7bdc16c (patch)
treec2dc1fc8904c75c892cd07d4db62a31e4780c4dc /askbot/management
parent5d5b10f0a8185794809ed901cf2acc61da8e32bd (diff)
downloadaskbot-13d2492046b597633bbb6f59bfc7e765b7bdc16c.tar.gz
askbot-13d2492046b597633bbb6f59bfc7e765b7bdc16c.tar.bz2
askbot-13d2492046b597633bbb6f59bfc7e765b7bdc16c.zip
fixed the delete unused tags
Diffstat (limited to 'askbot/management')
-rw-r--r--askbot/management/commands/delete_unused_tags.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/askbot/management/commands/delete_unused_tags.py b/askbot/management/commands/delete_unused_tags.py
index 9b7c3c1b..bc0b7d69 100644
--- a/askbot/management/commands/delete_unused_tags.py
+++ b/askbot/management/commands/delete_unused_tags.py
@@ -1,26 +1,28 @@
from django.core.management.base import NoArgsCommand
from django.db import transaction
from askbot import models
-from askbot.utils import console
+from askbot.utils.console import ProgressBar
+from askbot.conf import settings as askbot_settings
import sys
class Command(NoArgsCommand):
@transaction.commit_manually
def handle_noargs(self, **options):
tags = models.Tag.objects.all()
- count = 0
- print "Searching for unused tags:",
+ message = 'Searching for unused tags:'
total = tags.count()
+ tags = tags.iterator()
deleted_tags = list()
- for tag in tags:
+ for tag in ProgressBar(tags, total, message):
+ if tag.name == askbot_settings.GLOBAL_GROUP_NAME:#todo: temporary
+ continue
+ if tag.name.startswith('_internal_'):
+ continue
+
if not tag.threads.exists():
deleted_tags.append(tag.name)
tag.delete()
transaction.commit()
- count += 1
- progress = 100*float(count)/float(total)
- console.print_progress('%6.2f%%', progress)
- print '%6.2f%%' % 100
if deleted_tags:
found_count = len(deleted_tags)