forked from samuelclay/NewsBlur
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap_intel.py
31 lines (29 loc) · 1.33 KB
/
bootstrap_intel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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__