From a248d72f17a9a658d4c76c05961fa0ce1e7470b0 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Mon, 31 Aug 2015 09:09:43 -0400 Subject: [PATCH] Shelve work --- gratipay/billing/payday.py | 49 -------------------------------------- sql/branch.sql | 19 +++++++++++++++ sql/payday.sql | 13 ---------- 3 files changed, 19 insertions(+), 62 deletions(-) create mode 100644 sql/branch.sql diff --git a/gratipay/billing/payday.py b/gratipay/billing/payday.py index 9518eb9c36..407f33ebef 100644 --- a/gratipay/billing/payday.py +++ b/gratipay/billing/payday.py @@ -231,15 +231,6 @@ def f(p): return 1 else: holds[p.id] = hold - n_failures = sum(filter(None, threaded_map(f, participants))) - - # Record the number of failures - cursor.one(""" - UPDATE paydays - SET ncc_failing = %s - WHERE ts_end='1970-01-01T00:00:00+00'::timestamptz - RETURNING id - """, (n_failures,), default=NoPayday) # Update the values of card_hold_ok in our temporary table if not holds: @@ -402,32 +393,6 @@ def update_stats(self): FROM transfers WHERE "timestamp" >= %(ts_start)s ) - , our_tips AS ( - SELECT * - FROM our_transfers - WHERE context = 'tip' - ) - , our_pachinkos AS ( - SELECT * - FROM our_transfers - WHERE context = 'take' - ) - , our_exchanges AS ( - SELECT * - FROM exchanges - WHERE "timestamp" >= %(ts_start)s - ) - , our_achs AS ( - SELECT * - FROM our_exchanges - WHERE amount < 0 - ) - , our_charges AS ( - SELECT * - FROM our_exchanges - WHERE amount > 0 - AND status <> 'failed' - ) UPDATE paydays SET nactive = ( SELECT DISTINCT count(*) FROM ( @@ -436,21 +401,7 @@ def update_stats(self): SELECT tippee FROM our_transfers ) AS foo ) - , ntippers = (SELECT count(DISTINCT tipper) FROM our_transfers) - , ntips = (SELECT count(*) FROM our_tips) - , npachinko = (SELECT count(*) FROM our_pachinkos) - , pachinko_volume = (SELECT COALESCE(sum(amount), 0) FROM our_pachinkos) - , ntransfers = (SELECT count(*) FROM our_transfers) , transfer_volume = (SELECT COALESCE(sum(amount), 0) FROM our_transfers) - , nachs = (SELECT count(*) FROM our_achs) - , ach_volume = (SELECT COALESCE(sum(amount), 0) FROM our_achs) - , ach_fees_volume = (SELECT COALESCE(sum(fee), 0) FROM our_achs) - , ncharges = (SELECT count(*) FROM our_charges) - , charge_volume = ( - SELECT COALESCE(sum(amount + fee), 0) - FROM our_charges - ) - , charge_fees_volume = (SELECT COALESCE(sum(fee), 0) FROM our_charges) WHERE ts_end='1970-01-01T00:00:00+00'::timestamptz """, {'ts_start': self.ts_start}) diff --git a/sql/branch.sql b/sql/branch.sql new file mode 100644 index 0000000000..89a4016855 --- /dev/null +++ b/sql/branch.sql @@ -0,0 +1,19 @@ +BEGIN; + + ALTER TABLE paydays DROP COLUMN nparticipants; + ALTER TABLE paydays DROP COLUMN ntippers; + ALTER TABLE paydays DROP COLUMN ntips; + ALTER TABLE paydays DROP COLUMN ntransfers; + ALTER TABLE paydays DROP COLUMN ncc_failing; + ALTER TABLE paydays DROP COLUMN ncc_missing; + ALTER TABLE paydays DROP COLUMN ncharges; + ALTER TABLE paydays DROP COLUMN charge_volume; + ALTER TABLE paydays DROP COLUMN charge_fees_volume; + ALTER TABLE paydays DROP COLUMN nachs; + ALTER TABLE paydays DROP COLUMN ach_volume; + ALTER TABLE paydays DROP COLUMN ach_fees_volume; + ALTER TABLE paydays DROP COLUMN nach_failing; + ALTER TABLE paydays DROP COLUMN npachinko; + ALTER TABLE paydays DROP COLUMN pachinko_volume; + +END; diff --git a/sql/payday.sql b/sql/payday.sql index a3caa3d438..1853ce5f3b 100644 --- a/sql/payday.sql +++ b/sql/payday.sql @@ -206,16 +206,3 @@ CREATE TRIGGER process_draw BEFORE UPDATE OF is_drained ON payday_teams FOR EACH ROW WHEN (NEW.is_drained IS true AND OLD.is_drained IS NOT true) EXECUTE PROCEDURE process_draw(); - - --- Save the stats we already have - -UPDATE paydays - SET nparticipants = (SELECT count(*) FROM payday_participants) - , ncc_missing = ( - SELECT count(*) - FROM payday_participants - WHERE old_balance < giving_today - AND NOT has_credit_card - ) - WHERE ts_end='1970-01-01T00:00:00+00'::timestamptz;