mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-31 21:41:33 +00:00
Reformatting payment reports.
This commit is contained in:
parent
ab2b419aca
commit
0da18eb986
2 changed files with 17 additions and 7 deletions
|
@ -23,6 +23,8 @@ class Command(BaseCommand):
|
|||
limit = 100
|
||||
offset = options.get('offset')
|
||||
|
||||
ignore_user_ids = [18759, 30189, 64184, 254899, 37485, 260097, 244361, 2386, 133148, 102747, 113990, 67222, 5665, 213213, 274, 10462, 240747, 27473, 37748, 85501, 38646, 242379, 53887, 144792, 249582, 126886, 6337, 258479, 43075, 273339, 24347, 178338, 142873, 82601, 18776, 22356, 37524, 124160, 27551, 34427, 35953, 136492, 45476, 14922, 106089, 15848, 33187, 21913, 19860, 43097, 7257, 101133, 147496, 13500, 26762, 44189, 179498, 90799, 44003, 43825, 43861, 43847, 276609, 43007, 43041, 273707, 29652, 171964, 42045, 173859, 109149, 221251, 42344, 29359, 26284, 29251, 10387, 42502, 42043, 42036, 263720, 77766, 41870, 6589, 25411, 262875, 261455, 24292, 41529, 33303, 41343, 40422, 41146, 5561, 71937, 249531, 260228, 258502, 40883, 40859, 40832, 40608, 259295, 218791, 127438, 27354, 27009, 257426, 257289, 7450, 173558, 25773, 4136, 3404, 2251, 3492, 3397, 24927, 39968, 540, 24281, 24095, 24427, 39899, 39887, 17804, 23613, 116173, 3242, 23388, 2760, 22868, 22640, 39465, 39222, 39424, 39268, 238280, 143982, 21964, 246042, 252087, 202824, 38937, 19715, 38704, 139267, 249644, 38549, 249424, 224057, 248477, 236813, 36822, 189335, 139732, 242454, 18817, 37420, 37435, 178748, 206385, 200703, 233798, 177033, 19706, 244002, 167606, 73054, 50543, 19431, 211439, 239137, 36433, 60146, 167373, 19730, 253812]
|
||||
|
||||
while True:
|
||||
logging.debug(" ---> At %s" % offset)
|
||||
user_ids = PaymentHistory.objects.filter(payment_provider='paypal',
|
||||
|
@ -33,12 +35,15 @@ class Command(BaseCommand):
|
|||
break
|
||||
offset += limit
|
||||
for user_id in user_ids:
|
||||
if user_id in ignore_user_ids:
|
||||
# ignore_user_ids can be removed after 2016-05-17
|
||||
continue
|
||||
try:
|
||||
user = User.objects.get(pk=user_id)
|
||||
except User.DoesNotExist:
|
||||
logging.debug(" ***> Couldn't find paypal user_id=%s" % user_id)
|
||||
failed.append(user_id)
|
||||
|
||||
|
||||
if not user.profile.is_premium:
|
||||
user.profile.activate_premium()
|
||||
elif user.payments.all().count() != 1:
|
||||
|
|
|
@ -899,26 +899,31 @@ class PaymentHistory(models.Model):
|
|||
start_date.year, start_date.month, start_date.day,
|
||||
end_date.year, end_date.month, end_date.day,
|
||||
round(payments['avg'], 2), payments['sum'], payments['count'])
|
||||
return payments['sum']
|
||||
|
||||
print "\n\nMonthly Totals:"
|
||||
print "\nMonthly Totals:"
|
||||
month_totals = {}
|
||||
for m in reversed(range(months)):
|
||||
now = datetime.datetime.now()
|
||||
start_date = datetime.datetime(now.year, now.month, 1) - dateutil.relativedelta.relativedelta(months=m)
|
||||
end_time = start_date + datetime.timedelta(days=31)
|
||||
end_date = datetime.datetime(end_time.year, end_time.month, 1) - datetime.timedelta(seconds=1)
|
||||
_counter(start_date, end_date)
|
||||
|
||||
print "\n\nYearly Totals:"
|
||||
total = _counter(start_date, end_date)
|
||||
month_totals[start_date.strftime("%Y-%m")] = total
|
||||
|
||||
print "\nYearly Totals:"
|
||||
year_totals = {}
|
||||
years = datetime.datetime.now().year - 2009
|
||||
for y in reversed(range(years)):
|
||||
now = datetime.datetime.now()
|
||||
start_date = datetime.datetime(now.year, 1, 1) - dateutil.relativedelta.relativedelta(years=y)
|
||||
end_time = start_date + datetime.timedelta(days=365)
|
||||
end_date = datetime.datetime(end_time.year, end_time.month, 30) - datetime.timedelta(seconds=1)
|
||||
_counter(start_date, end_date)
|
||||
if end_date > now: end_date = now
|
||||
year_totals[now.year - y] = _counter(start_date, end_date)
|
||||
|
||||
total = cls.objects.all().aggregate(sum=Sum('payment_amount'))
|
||||
print "\n\nTotal: $%s" % total['sum']
|
||||
print "\nTotal: $%s" % total['sum']
|
||||
|
||||
class MRedeemedCode(mongo.Document):
|
||||
user_id = mongo.IntField()
|
||||
|
|
Loading…
Add table
Reference in a new issue