Forcing all unread counts to be counted from primary mongo.

This commit is contained in:
Samuel Clay 2012-10-30 10:57:12 -07:00
parent 34898004d5
commit fa692d746c
2 changed files with 5 additions and 3 deletions

4
fabfile.py vendored
View file

@ -456,8 +456,8 @@ def setup_mongoengine():
with settings(warn_only=True):
run('rm -fr mongoengine')
run('git clone https://github.com/MongoEngine/mongoengine.git')
sudo('rm -f /usr/local/lib/python2.7/dist-packages/mongoengine')
sudo('rm -f /usr/local/lib/python2.7/dist-packages/mongoengine-*')
sudo('rm -fr /usr/local/lib/python2.7/dist-packages/mongoengine')
sudo('rm -fr /usr/local/lib/python2.7/dist-packages/mongoengine-*')
sudo('ln -s %s /usr/local/lib/python2.7/dist-packages/mongoengine' %
os.path.join(env.VENDOR_PATH, 'mongoengine/mongoengine'))

View file

@ -6,6 +6,7 @@ import urllib2
import xml.sax
import redis
import random
import pymongo
from django.core.cache import cache
from django.conf import settings
from django.db import IntegrityError
@ -519,7 +520,8 @@ class Dispatcher:
if self.options['compute_scores']:
stories = MStory.objects(story_feed_id=feed.pk,
story_date__gte=UNREAD_CUTOFF)
story_date__gte=UNREAD_CUTOFF)\
.read_preference(pymongo.ReadPreference.PRIMARY)
stories = Feed.format_stories(stories, feed.pk)
logging.debug(u' ---> [%-30s] ~FYComputing scores: ~SB%s stories~SN with ~SB%s subscribers ~SN(%s/%s/%s)' % (
feed.title[:30], len(stories), user_subs.count(),