Fixing emergency bug around trimming feeds where the cursor is changing. Dammit mongo.

This commit is contained in:
Samuel Clay 2011-12-14 10:49:00 -08:00
parent fd2b778363
commit 999b12e00b

View file

@ -772,7 +772,11 @@ class Feed(models.Model):
if stories.count() > trim_cutoff:
if verbose:
print 'Found %s stories in %s. Trimming to %s...' % (stories.count(), self, trim_cutoff)
story_trim_date = stories[trim_cutoff].story_date
try:
story_trim_date = stories[trim_cutoff].story_date
except IndexError, e:
logging.debug(' ***> [%-30s] Error trimming feed: %s' % (self, e))
return
extra_stories = MStory.objects(story_feed_id=self.pk, story_date__lte=story_trim_date)
extra_stories.delete()
# print "Deleted stories, %s left." % MStory.objects(story_feed_id=self.pk).count()