From 33183967b3688cfe4537862eed49d7e4370c1b13 Mon Sep 17 00:00:00 2001 From: Samuel Clay Date: Sat, 23 Jan 2021 14:20:19 -0500 Subject: [PATCH] Checking if a feed has any notifications on it, set a max of 30 min fetch (yes this is a pretty good way of getting your feeds to fetch faster, but youll have to deal with the notifications). --- apps/rss_feeds/models.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/rss_feeds/models.py b/apps/rss_feeds/models.py index 9707dabf1..b70baeef6 100644 --- a/apps/rss_feeds/models.py +++ b/apps/rss_feeds/models.py @@ -2099,12 +2099,15 @@ class Feed(models.Model): if self.min_to_decay and not force and not premium_speed: return self.min_to_decay + from apps.notifications.models import MUserFeedNotification + if premium_speed: self.active_premium_subscribers += 1 spd = self.stories_last_month / 30.0 subs = (self.active_premium_subscribers + ((self.active_subscribers - self.active_premium_subscribers) / 10.0)) + notification_count = MUserFeedNotification.objects.filter(feed_id=self.pk).count() # Calculate sub counts: # SELECT COUNT(*) FROM feeds WHERE active_premium_subscribers > 10 AND stories_last_month >= 30; # SELECT COUNT(*) FROM feeds WHERE active_premium_subscribers > 1 AND active_premium_subscribers < 10 AND stories_last_month >= 30; @@ -2163,6 +2166,10 @@ class Feed(models.Model): if len(fetch_history['push_history']): total = total * 12 + # Any notifications means a 30 min minumum + if notification_count > 0: + total = min(total, 30) + # 4 hour max for premiums, 48 hour max for free if subs >= 1: total = min(total, 60*4*1)