Fixing cutoff date when retrieving stories.

This commit is contained in:
Samuel Clay 2013-12-05 15:10:09 -08:00
parent 904e908b61
commit 6040e1d97e
2 changed files with 5 additions and 3 deletions

View file

@ -169,7 +169,7 @@ class UserSubscription(models.Model):
return story_hashes
def get_stories(self, offset=0, limit=6, order='newest', read_filter='all', withscores=False,
hashes_only=False, cutoff_date=None):
hashes_only=False, cutoff_date=None, default_cutoff_date=None):
r = redis.Redis(connection_pool=settings.REDIS_STORY_HASH_POOL)
rt = redis.Redis(connection_pool=settings.REDIS_STORY_HASH_TEMP_POOL)
ignore_user_stories = False
@ -207,6 +207,8 @@ class UserSubscription(models.Model):
if not cutoff_date:
if read_filter == "unread":
cutoff_date = self.mark_read_date
elif default_cutoff_date:
cutoff_date = default_cutoff_date
else:
cutoff_date = datetime.datetime.now() - datetime.timedelta(days=settings.DAYS_OF_UNREAD)

View file

@ -548,7 +548,7 @@ def load_single_feed(request, feed_id):
message = "You must be a premium subscriber to search."
elif usersub and (read_filter == 'unread' or order == 'oldest'):
stories = usersub.get_stories(order=order, read_filter=read_filter, offset=offset, limit=limit,
cutoff_date=user.profile.unread_cutoff)
default_cutoff_date=user.profile.unread_cutoff)
else:
stories = feed.get_stories(offset, limit)
@ -1019,7 +1019,7 @@ def unread_story_hashes__old(request):
unread_feed_story_hashes[feed_id] = us.get_stories(read_filter='unread', limit=500,
withscores=include_timestamps,
hashes_only=True,
cutoff_date=user.profile.unread_cutoff)
default_cutoff_date=user.profile.unread_cutoff)
story_hash_count += len(unread_feed_story_hashes[feed_id])
logging.user(request, "~FYLoading ~FCunread story hashes~FY: ~SB%s feeds~SN (%s story hashes)" %