From aa4bf71b34d9a7d7a271e44cc4f4487f92f722d1 Mon Sep 17 00:00:00 2001 From: Samuel Clay Date: Fri, 29 Mar 2013 14:14:29 -0700 Subject: [PATCH] Upping feed fetching by quite a bit. --- apps/rss_feeds/models.py | 7 +++---- apps/rss_feeds/tasks.py | 2 +- utils/reimport_stripe_history.py | 4 +++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/rss_feeds/models.py b/apps/rss_feeds/models.py index fd54a4b01..d8f0ee8ef 100644 --- a/apps/rss_feeds/models.py +++ b/apps/rss_feeds/models.py @@ -1245,14 +1245,13 @@ class Feed(models.Model): slow_punishment = 6 * self.last_load_time total = max(10, int(updates_per_day_delay + subscriber_bonus + slow_punishment)) - if self.active_premium_subscribers > 5: + if self.active_premium_subscribers > 4: total = min(total, 60) # 1 hour minimum for premiums - if ((self.stories_last_month == 0 or self.average_stories_per_month == 0)): - total = total * random.randint(1, 24) - if self.is_push: total = total * 20 + elif ((self.stories_last_month == 0 or self.average_stories_per_month == 0)): + total = total * random.randint(1, 24) # 1 month max if total > 60*24*30: diff --git a/apps/rss_feeds/tasks.py b/apps/rss_feeds/tasks.py index 8340d1932..adea18805 100644 --- a/apps/rss_feeds/tasks.py +++ b/apps/rss_feeds/tasks.py @@ -29,7 +29,7 @@ class TaskFeeds(Task): next_scheduled_update__lte=now, active=True, active_subscribers__gte=1 - ).order_by('?')[:600] + ).order_by('?')[:800] active_count = feeds.count() # Force refresh feeds diff --git a/utils/reimport_stripe_history.py b/utils/reimport_stripe_history.py index a2a9eba30..836e5335c 100644 --- a/utils/reimport_stripe_history.py +++ b/utils/reimport_stripe_history.py @@ -1,7 +1,7 @@ import stripe, datetime, time stripe.api_key = settings.STRIPE_SECRET -week = (datetime.datetime.now() - datetime.timedelta(days=7)).strftime('%s') +week = (datetime.datetime.now() - datetime.timedelta(days=14)).strftime('%s') failed = [] limit = 100 offset = 0 @@ -29,6 +29,8 @@ while True: user.profile.activate_premium() elif user.payments.all().count() != 1: user.profile.setup_premium_history() + elif user.profile.premium_expire > datetime.datetime.now() + datetime.timedelta(days=365): + user.profile.setup_premium_history() else: print " ---> %s is fine" % username except stripe.APIConnectionError: