mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-04-13 09:42:01 +00:00
Syncing redis on premium upgrade to sync new unread date possibilities for archive users.
This commit is contained in:
parent
1dd921fa61
commit
2792e7305a
8 changed files with 17 additions and 31 deletions
5
Makefile
5
Makefile
|
@ -32,7 +32,10 @@ nb: pull
|
|||
- docker exec newsblur_web ./manage.py loaddata config/fixtures/bootstrap.json
|
||||
coffee:
|
||||
- coffee -c -w **/*.coffee
|
||||
|
||||
migrations:
|
||||
- docker exec -it newsblur_web ./manage.py makemigrations
|
||||
migrate:
|
||||
- docker exec -it newsblur_web ./manage.py migrate
|
||||
shell:
|
||||
- docker exec -it newsblur_web ./manage.py shell_plus
|
||||
bash:
|
||||
|
|
|
@ -46,6 +46,7 @@ class Profile(models.Model):
|
|||
view_settings = models.TextField(default="{}")
|
||||
collapsed_folders = models.TextField(default="[]")
|
||||
feed_pane_size = models.IntegerField(default=242)
|
||||
days_of_unread = models.IntegerField(default=settings.DAYS_OF_UNREAD)
|
||||
tutorial_finished = models.BooleanField(default=False)
|
||||
hide_getting_started = models.BooleanField(default=False, null=True, blank=True)
|
||||
has_setup_feeds = models.BooleanField(default=False, null=True, blank=True)
|
||||
|
@ -71,7 +72,7 @@ class Profile(models.Model):
|
|||
@property
|
||||
def unread_cutoff(self, force_premium=False, force_archive=False):
|
||||
if self.is_archive or force_archive:
|
||||
return datetime.datetime.utcnow() - datetime.timedelta(days=settings.DAYS_OF_UNREAD_ARCHIVE)
|
||||
return datetime.datetime.utcnow() - datetime.timedelta(days=self.days_of_unread)
|
||||
if self.is_premium or force_premium:
|
||||
return datetime.datetime.utcnow() - datetime.timedelta(days=settings.DAYS_OF_UNREAD)
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ class UserSubscription(models.Model):
|
|||
feed_ids = [sub.feed_id for sub in usersubs]
|
||||
if not feed_ids:
|
||||
return story_hashes
|
||||
|
||||
|
||||
current_time = int(time.time() + 60*60*24)
|
||||
if not cutoff_date:
|
||||
cutoff_date = datetime.datetime.now() - datetime.timedelta(days=UserSubscription.days_of_story_hashes_for_user(user_id))
|
||||
|
@ -1160,10 +1160,10 @@ class RUserStory:
|
|||
message = None
|
||||
if story.story_date < user.profile.unread_cutoff:
|
||||
if user.profile.is_archive:
|
||||
message = "Story is more than %s days old, cannot mark as unread." % (
|
||||
settings.DAYS_OF_UNREAD_ARCHIVE)
|
||||
message = "Story is more than %s days old, change your days of unreads under Preferences." % (
|
||||
user.profile.days_of_unread)
|
||||
elif user.profile.is_premium:
|
||||
message = "Story is more than %s days old, cannot mark as unread." % (
|
||||
message = "Story is more than %s days old. Premium Archive accounts can mark any story as unread." % (
|
||||
settings.DAYS_OF_UNREAD)
|
||||
elif story.story_date > user.profile.unread_cutoff_premium:
|
||||
message = "Story is more than %s days old. Premium accounts can mark unread up to %s days, and Premium Archive accounts can mark any story as unread." % (
|
||||
|
|
|
@ -656,6 +656,7 @@ class Feed(models.Model):
|
|||
def setup_feed_for_premium_subscribers(self):
|
||||
self.count_subscribers()
|
||||
self.set_next_scheduled_update(verbose=settings.DEBUG)
|
||||
self.sync_redis()
|
||||
|
||||
def check_feed_link_for_feed_address(self):
|
||||
@timelimit(10)
|
||||
|
|
|
@ -163,26 +163,6 @@ _.extend(NEWSBLUR.ReaderPreferences.prototype, {
|
|||
'Timezone'
|
||||
])
|
||||
]),
|
||||
$.make('div', { className: 'NB-preference NB-preference-ssl' }, [
|
||||
$.make('div', { className: 'NB-preference-options' }, [
|
||||
$.make('div', [
|
||||
$.make('input', { id: 'NB-preference-ssl-1', type: 'radio', name: 'ssl', value: 0 }),
|
||||
$.make('label', { 'for': 'NB-preference-ssl-1' }, [
|
||||
'Use a standard connection'
|
||||
])
|
||||
]),
|
||||
$.make('div', [
|
||||
$.make('input', { id: 'NB-preference-ssl-2', type: 'radio', name: 'ssl', value: 1 }),
|
||||
$.make('label', { 'for': 'NB-preference-ssl-2' }, [
|
||||
$.make('img', { src: NEWSBLUR.Globals.MEDIA_URL+'/img/icons/circular/g_icn_lock.png' }),
|
||||
'Only use a secure https connection'
|
||||
])
|
||||
])
|
||||
]),
|
||||
$.make('div', { className: 'NB-preference-label'}, [
|
||||
'SSL'
|
||||
])
|
||||
]),
|
||||
$.make('div', { className: 'NB-preference NB-preference-showunreadcountsintitle' }, [
|
||||
$.make('div', { className: 'NB-preference-options' }, [
|
||||
$.make('div', [
|
||||
|
|
|
@ -20,7 +20,7 @@ SESSION_COOKIE_DOMAIN = 'localhost'
|
|||
|
||||
DOCKERBUILD = True
|
||||
DEBUG = False
|
||||
DEBUG = True
|
||||
# DEBUG = True
|
||||
|
||||
# DEBUG_ASSETS controls JS/CSS asset packaging. Turning this off requires you to run
|
||||
# `./manage.py collectstatic` first. Turn this on for development so you can see
|
||||
|
@ -33,7 +33,7 @@ DEBUG_ASSETS = True
|
|||
# down verbosity.
|
||||
DEBUG_QUERIES = DEBUG
|
||||
DEBUG_QUERIES_SUMMARY_ONLY = True
|
||||
DEBUG_QUERIES_SUMMARY_ONLY = False
|
||||
# DEBUG_QUERIES_SUMMARY_ONLY = False
|
||||
|
||||
MEDIA_URL = '/media/'
|
||||
IMAGES_URL = '/imageproxy'
|
||||
|
|
|
@ -764,7 +764,6 @@ REDIS_POOL = redis.ConnectionPool(host=REDIS_USER['host'], port=
|
|||
REDIS_ANALYTICS_POOL = redis.ConnectionPool(host=REDIS_USER['host'], port=REDIS_PORT, db=2, decode_responses=True)
|
||||
REDIS_STATISTICS_POOL = redis.ConnectionPool(host=REDIS_USER['host'], port=REDIS_PORT, db=3, decode_responses=True)
|
||||
REDIS_FEED_UPDATE_POOL = redis.ConnectionPool(host=REDIS_USER['host'], port=REDIS_PORT, db=4, decode_responses=True)
|
||||
# REDIS_STORY_HASH_POOL2 = redis.ConnectionPool(host=REDIS_USER['host'], port=REDIS_PORT, db=8) # Only used when changing DAYS_OF_UNREAD
|
||||
REDIS_STORY_HASH_TEMP_POOL = redis.ConnectionPool(host=REDIS_USER['host'], port=REDIS_PORT, db=10, decode_responses=True)
|
||||
# REDIS_CACHE_POOL = redis.ConnectionPool(host=REDIS_USER['host'], port=REDIS_PORT, db=6) # Duped in CACHES
|
||||
REDIS_STORY_HASH_POOL = redis.ConnectionPool(host=REDIS_STORY['host'], port=REDIS_PORT, db=1, decode_responses=True)
|
||||
|
|
|
@ -914,9 +914,11 @@ class FeedFetcherWorker:
|
|||
logging.debug(" ***> [%-30s] ~BMRedis is unavailable for real-time." % (feed.log_title[:30],))
|
||||
|
||||
def count_unreads_for_subscribers(self, feed):
|
||||
user_subs = UserSubscription.objects.filter(feed=feed,
|
||||
subscriber_expire = datetime.datetime.now() - datetime.timedelta(days=settings.SUBSCRIBER_EXPIRE)
|
||||
|
||||
user_subs = UserSubscription.objects.filter(feed=feed,
|
||||
active=True,
|
||||
user__profile__last_seen_on__gte=feed.unread_cutoff)\
|
||||
user__profile__last_seen_on__gte=subscriber_expire)\
|
||||
.order_by('-last_read_date')
|
||||
|
||||
if not user_subs.count():
|
||||
|
|
Loading…
Add table
Reference in a new issue