From abc522c12f15efe40c358e2ff280bf7d223a85bb Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Thu, 14 May 2015 13:15:33 -0400 Subject: [PATCH] Remove the settle_tip_graph function entirely --- gratipay/billing/payday.py | 17 +++-------------- sql/payday.sql | 11 ----------- tests/py/test_billing_payday.py | 4 +--- 3 files changed, 4 insertions(+), 28 deletions(-) diff --git a/gratipay/billing/payday.py b/gratipay/billing/payday.py index f5cba78945..052ffec326 100644 --- a/gratipay/billing/payday.py +++ b/gratipay/billing/payday.py @@ -180,7 +180,6 @@ def payin(self): self.db.run(""" DROP FUNCTION process_take(); DROP FUNCTION process_tip(); - DROP FUNCTION settle_tip_graph(); DROP FUNCTION transfer(text, text, numeric, context_type); """) @@ -274,17 +273,9 @@ def f(p): @staticmethod def transfer_tips(cursor): - cursor.run(""" - - UPDATE payday_tips t - SET is_funded = true - FROM payday_participants p - WHERE p.username = t.tipper - AND p.card_hold_ok; - - SELECT settle_tip_graph(); - - """) + """Trigger the process_tip function for each row in payday_tips. + """ + cursor.run("UPDATE payday_tips SET is_funded=true;") @staticmethod @@ -310,8 +301,6 @@ def transfer_takes(cursor, ts_start): ) IS NULL ORDER BY t.team, t.ctime DESC; - SELECT settle_tip_graph(); - """, dict(ts_start=ts_start)) diff --git a/sql/payday.sql b/sql/payday.sql index 369ee0935e..5f9b26997f 100644 --- a/sql/payday.sql +++ b/sql/payday.sql @@ -151,17 +151,6 @@ CREATE TRIGGER process_take AFTER INSERT ON payday_takes FOR EACH ROW EXECUTE PROCEDURE process_take(); --- Create a function to settle whole tip graph - -CREATE OR REPLACE FUNCTION settle_tip_graph() RETURNS void AS $$ - BEGIN - UPDATE payday_tips - SET is_funded = true - WHERE is_funded IS NOT true; - END; -$$ LANGUAGE plpgsql; - - -- Save the stats we already have UPDATE paydays diff --git a/tests/py/test_billing_payday.py b/tests/py/test_billing_payday.py index 02a88e13c0..3d199aea5e 100644 --- a/tests/py/test_billing_payday.py +++ b/tests/py/test_billing_payday.py @@ -363,8 +363,7 @@ def test_payin_doesnt_make_null_transfers(self): assert not transfers0 def test_transfer_tips(self): - alice = self.make_participant('alice', claimed_time='now', balance=1, - last_bill_result='') + alice = self.make_participant('alice', claimed_time='now', balance=1) alice.set_tip_to(self.janet, D('0.51')) alice.set_tip_to(self.homer, D('0.50')) payday = Payday.start() @@ -372,7 +371,6 @@ def test_transfer_tips(self): payday.prepare(cursor, payday.ts_start) payday.transfer_tips(cursor) payday.update_balances(cursor) - alice = Participant.from_id(alice.id) assert Participant.from_id(alice.id).balance == D('0.49') assert Participant.from_id(self.janet.id).balance == D('0.51') assert Participant.from_id(self.homer.id).balance == 0