mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Forcing the feed fetcher to not count scores when there's replica lag. God this had better work.
This commit is contained in:
parent
73cd4b6b5b
commit
2fa00fd737
3 changed files with 18 additions and 4 deletions
|
@ -48,9 +48,14 @@ class UpdateFeeds(Task):
|
|||
from apps.rss_feeds.models import Feed
|
||||
from apps.statistics.models import MStatistics
|
||||
|
||||
mongodb_replication_lag = int(MStatistics.get('mongodb_replication_lag', 0))
|
||||
compute_scores = bool(mongodb_replication_lag < 250)
|
||||
|
||||
options = {
|
||||
'fake': bool(MStatistics.get('fake_fetch')),
|
||||
'quick': float(MStatistics.get('quick_fetch', 0)),
|
||||
'compute_scores': compute_scores,
|
||||
'mongodb_replication_lag': mongodb_replication_lag,
|
||||
}
|
||||
|
||||
if not isinstance(feed_pks, list):
|
||||
|
@ -88,9 +93,15 @@ class PushFeeds(Task):
|
|||
|
||||
def run(self, feed_id, xml, **kwargs):
|
||||
from apps.rss_feeds.models import Feed
|
||||
from apps.statistics.models import MStatistics
|
||||
|
||||
mongodb_replication_lag = int(MStatistics.get('mongodb_replication_lag', 0))
|
||||
compute_scores = bool(mongodb_replication_lag < 250)
|
||||
|
||||
options = {
|
||||
'feed_xml': xml
|
||||
'feed_xml': xml,
|
||||
'compute_scores': compute_scores,
|
||||
'mongodb_replication_lag': mongodb_replication_lag,
|
||||
}
|
||||
feed = Feed.objects.get(pk=feed_id)
|
||||
feed.update(options=options)
|
||||
|
|
|
@ -12,7 +12,7 @@ def mongo_max_replication_lag(connection):
|
|||
if member_state == PRIMARY_STATE:
|
||||
primary_optime = optime.time
|
||||
elif member_state == SECONDARY_STATE:
|
||||
if not oldest_secondary_optime or optime.time < oldest_secondary_optime.time:
|
||||
if not oldest_secondary_optime or optime.time < oldest_secondary_optime:
|
||||
oldest_secondary_optime = optime.time
|
||||
|
||||
if not primary_optime or not oldest_secondary_optime:
|
||||
|
|
|
@ -488,14 +488,17 @@ class Dispatcher:
|
|||
sub.needs_unread_recalc = True
|
||||
sub.save()
|
||||
|
||||
self.calculate_feed_scores_with_stories(user_subs, stories_db)
|
||||
self.calculate_feed_scores_with_stories(user_subs, stories_db, feed)
|
||||
|
||||
@timelimit(10)
|
||||
def calculate_feed_scores_with_stories(self, user_subs, stories_db):
|
||||
def calculate_feed_scores_with_stories(self, user_subs, stories_db, feed):
|
||||
if self.options['compute_scores']:
|
||||
for sub in user_subs:
|
||||
silent = False if self.options['verbose'] >= 2 else True
|
||||
sub.calculate_feed_scores(silent=silent, stories_db=stories_db)
|
||||
else:
|
||||
logging.debug(u' ---> [%-30s] ~FYSkipping computing scores: ~SB~BR~FW%s seconds~SN~FY of mongodb lag' % (
|
||||
feed.title[:30], self.options.get('mongodb_replication_lag')))
|
||||
|
||||
def add_jobs(self, feeds_queue, feeds_count=1):
|
||||
""" adds a feed processing job to the pool
|
||||
|
|
Loading…
Add table
Reference in a new issue