Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Shelve work
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed Aug 31, 2015
1 parent 28ac16d commit a248d72
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 62 deletions.
49 changes: 0 additions & 49 deletions gratipay/billing/payday.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 (
Expand All @@ -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})
Expand Down
19 changes: 19 additions & 0 deletions sql/branch.sql
Original file line number Diff line number Diff line change
@@ -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;
13 changes: 0 additions & 13 deletions sql/payday.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit a248d72

Please sign in to comment.