Skip to content

Commit

Permalink
Adding a migration for intelligence classifiers to include social_use…
Browse files Browse the repository at this point in the history
…r_id, where it didn't exist before.
  • Loading branch information
samuelclay committed Jun 22, 2012
1 parent 5df6637 commit d5d6a6c
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions utils/bootstrap_intel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import sys
from mongoengine.queryset import OperationError
from mongoengine.base import ValidationError
from apps.analyzer.models import MClassifierFeed
from apps.analyzer.models import MClassifierAuthor
from apps.analyzer.models import MClassifierTag
from apps.analyzer.models import MClassifierTitle

for classifier_cls in [MClassifierFeed, MClassifierAuthor,
MClassifierTag, MClassifierTitle]:
print " ================================================================= "
print " Now on %s " % classifier_cls.__name__
print " ================================================================= "
classifiers = classifier_cls.objects.filter(social_user_id__exists=False)
count = classifiers.count()
print " ---> Found %s classifiers" % count
for i, classifier in enumerate(classifiers):
if i % 1000 == 0:
print " ---> %s / %s" % (i, count)
sys.stdout.flush()
classifier.social_user_id = 0
try:
classifier.save()
except OperationError, e:
print " ***> Operation error on: %s" % e
sys.stdout.flush()
# classifier.delete()
except ValidationError, e:
print " ***> ValidationError error on: %s" % e
print " ***> Original classifier: %s" % classifier.__dict__

0 comments on commit d5d6a6c

Please sign in to comment.