mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-21 05:45:13 +00:00
Merge branch 'master' into circular
* master: Fixing stripe reimport Upping feed fetching by quite a bit. Fixing double counting stripe payment bug by clearing out striep purchase history when inserting.
This commit is contained in:
commit
0f53acdf6d
4 changed files with 16 additions and 6 deletions
|
@ -194,6 +194,13 @@ class Profile(models.Model):
|
||||||
stripe.api_key = settings.STRIPE_SECRET
|
stripe.api_key = settings.STRIPE_SECRET
|
||||||
stripe_customer = stripe.Customer.retrieve(self.stripe_id)
|
stripe_customer = stripe.Customer.retrieve(self.stripe_id)
|
||||||
stripe_payments = stripe.Charge.all(customer=stripe_customer.id).data
|
stripe_payments = stripe.Charge.all(customer=stripe_customer.id).data
|
||||||
|
|
||||||
|
existing_history = PaymentHistory.objects.filter(user=self.user,
|
||||||
|
payment_provider='stripe')
|
||||||
|
if existing_history.count():
|
||||||
|
print " ---> Deleting existing history: %s stripe payments" % existing_history.count()
|
||||||
|
existing_history.delete()
|
||||||
|
|
||||||
for payment in stripe_payments:
|
for payment in stripe_payments:
|
||||||
created = datetime.datetime.fromtimestamp(payment.created)
|
created = datetime.datetime.fromtimestamp(payment.created)
|
||||||
PaymentHistory.objects.create(user=self.user,
|
PaymentHistory.objects.create(user=self.user,
|
||||||
|
|
|
@ -1248,14 +1248,13 @@ class Feed(models.Model):
|
||||||
slow_punishment = 6 * self.last_load_time
|
slow_punishment = 6 * self.last_load_time
|
||||||
total = max(10, int(updates_per_day_delay + subscriber_bonus + slow_punishment))
|
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
|
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:
|
if self.is_push:
|
||||||
total = total * 20
|
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
|
# 1 month max
|
||||||
if total > 60*24*30:
|
if total > 60*24*30:
|
||||||
|
|
|
@ -29,7 +29,7 @@ class TaskFeeds(Task):
|
||||||
next_scheduled_update__lte=now,
|
next_scheduled_update__lte=now,
|
||||||
active=True,
|
active=True,
|
||||||
active_subscribers__gte=1
|
active_subscribers__gte=1
|
||||||
).order_by('?')[:600]
|
).order_by('?')[:800]
|
||||||
active_count = feeds.count()
|
active_count = feeds.count()
|
||||||
|
|
||||||
# Force refresh feeds
|
# Force refresh feeds
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import stripe, datetime, time
|
import stripe, datetime, time
|
||||||
stripe.api_key = settings.STRIPE_SECRET
|
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 = []
|
failed = []
|
||||||
limit = 100
|
limit = 100
|
||||||
offset = 0
|
offset = 0
|
||||||
|
@ -29,6 +29,10 @@ while True:
|
||||||
user.profile.activate_premium()
|
user.profile.activate_premium()
|
||||||
elif user.payments.all().count() != 1:
|
elif user.payments.all().count() != 1:
|
||||||
user.profile.setup_premium_history()
|
user.profile.setup_premium_history()
|
||||||
|
elif not user.profile.premium_expire:
|
||||||
|
user.profile.setup_premium_history()
|
||||||
|
elif user.profile.premium_expire > datetime.datetime.now() + datetime.timedelta(days=365):
|
||||||
|
user.profile.setup_premium_history()
|
||||||
else:
|
else:
|
||||||
print " ---> %s is fine" % username
|
print " ---> %s is fine" % username
|
||||||
except stripe.APIConnectionError:
|
except stripe.APIConnectionError:
|
||||||
|
|
Loading…
Add table
Reference in a new issue