NewsBlur/utils/archive/bootstrap_intel.py
Samuel Clay 0d6cb69548 Merge branch 'django1.11' into django2.0
* django1.11: (73 commits)
  Switching to new celery 4 standalone binary.
  Fixing various mongo data calls.
  Upgrading to latest celery 4 (holy moly), which required some big changes to project layout. Still needs supervisor scripts updated.
  Removing unused log on cookies.
  I believe this Context wrapping is still preserved. See this django ticket: https://code.djangoproject.com/ticket/28125. Reverting this fixes the error, so I'm assuming this is that type of render.
  Have to revert 3f122d5e03 because this broke existing sessions (logged me out) because the model has changed and the serialized model stored in redis no longer matches. Whew, this took a while to figure out.
  Upgrading redis cache.
  Adding cookies to path inspector.
  Removing dupe db log.
  Fixing missing DB logs (redis and mongo) due to this change in django 1.8: "connections.queries is now a read-only attribute."
  Removing migrations that set a default date of 2020-05-08. Not sure why this was committed. I thought we resolved the issue with default datetimes?
  Fixing CallableBool.
  Missing import
  Fixing runtime errors on django 1.10
  Fixing OAuth connect.
  Fixing various django1.9 issues, mainly around templates.
  BASE_DIR
  Not every story is from a feed.
  Styling background colors for newsletters.
  Styling more newsletter elements.
  ...
2020-06-30 12:34:59 -04:00

31 lines
1.4 KiB
Python

import sys
from mongoengine.queryset import OperationError
from mongoengine.errors 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 as e:
print((" ***> Operation error on: %s" % e))
sys.stdout.flush()
# classifier.delete()
except ValidationError as e:
print((" ***> ValidationError error on: %s" % e))
print((" ***> Original classifier: %s" % classifier.__dict__))