mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-21 05:45:13 +00:00
Expiration unread stories key after 24 hours.
This commit is contained in:
parent
b62b859186
commit
a37c8593f7
1 changed files with 3 additions and 6 deletions
|
@ -133,8 +133,6 @@ class UserSubscription(models.Model):
|
||||||
cutoff_date = user.profile.unread_cutoff
|
cutoff_date = user.profile.unread_cutoff
|
||||||
feed_counter = 0
|
feed_counter = 0
|
||||||
unread_ranked_stories_keys = []
|
unread_ranked_stories_keys = []
|
||||||
expire_unread_stories_key = False
|
|
||||||
after_unread_pipeline = r.pipeline()
|
|
||||||
|
|
||||||
read_dates = dict()
|
read_dates = dict()
|
||||||
manual_unread_pipeline = r.pipeline()
|
manual_unread_pipeline = r.pipeline()
|
||||||
|
@ -167,7 +165,7 @@ class UserSubscription(models.Model):
|
||||||
# TODO: Remove above +1 and switch below to AGGREGATE='MAX', which may obviate the need
|
# TODO: Remove above +1 and switch below to AGGREGATE='MAX', which may obviate the need
|
||||||
# for the U:%s keys and just work with the zF: & RS: directly into zU:
|
# for the U:%s keys and just work with the zF: & RS: directly into zU:
|
||||||
pipeline.sdiffstore(unread_stories_key, stories_key, read_stories_key)
|
pipeline.sdiffstore(unread_stories_key, stories_key, read_stories_key)
|
||||||
expire_unread_stories_key = True
|
pipeline.expire(unread_stories_key, 24*60*60) # 24 hours
|
||||||
else:
|
else:
|
||||||
min_score = 0
|
min_score = 0
|
||||||
unread_stories_key = stories_key
|
unread_stories_key = stories_key
|
||||||
|
@ -179,6 +177,7 @@ class UserSubscription(models.Model):
|
||||||
min_score, max_score = max_score, min_score
|
min_score, max_score = max_score, min_score
|
||||||
|
|
||||||
pipeline.zinterstore(unread_ranked_stories_key, [sorted_stories_key, unread_stories_key])
|
pipeline.zinterstore(unread_ranked_stories_key, [sorted_stories_key, unread_stories_key])
|
||||||
|
pipeline.expire(unread_ranked_stories_key, 24*60*60) # 24 hours
|
||||||
if order == 'oldest':
|
if order == 'oldest':
|
||||||
pipeline.zremrangebyscore(unread_ranked_stories_key, 0, min_score-1)
|
pipeline.zremrangebyscore(unread_ranked_stories_key, 0, min_score-1)
|
||||||
pipeline.zremrangebyscore(unread_ranked_stories_key, max_score+1, 2*max_score)
|
pipeline.zremrangebyscore(unread_ranked_stories_key, max_score+1, 2*max_score)
|
||||||
|
@ -221,8 +220,6 @@ class UserSubscription(models.Model):
|
||||||
if store_stories_key:
|
if store_stories_key:
|
||||||
r.zunionstore(store_stories_key, unread_ranked_stories_keys, aggregate="MAX")
|
r.zunionstore(store_stories_key, unread_ranked_stories_keys, aggregate="MAX")
|
||||||
|
|
||||||
after_unread_pipeline.execute()
|
|
||||||
|
|
||||||
if not store_stories_key:
|
if not store_stories_key:
|
||||||
return story_hashes
|
return story_hashes
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue