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).

This commit is contained in:
Samuel Clay 2021-01-23 14:20:19 -05:00
parent d2f1a417c9
commit 33183967b3

View file

@ -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)