From cdba1b11a3c7f685bd4009fd3d1bf27f030deffe Mon Sep 17 00:00:00 2001 From: Paul Kuruvilla Date: Tue, 5 Apr 2016 12:21:25 +0530 Subject: [PATCH] Add script to fix stale cached values Earlier (in Gratipay 1.0), we used to fund tips using the Gratipay balance that participants had. We used to refresh these values after every Payday. Now that we've moved to charging in arrears and never using one's balance to fund tips - the old 'funded' values have to be corrected. --- sql/branch.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 sql/branch.py diff --git a/sql/branch.py b/sql/branch.py new file mode 100644 index 0000000000..30c3621ce0 --- /dev/null +++ b/sql/branch.py @@ -0,0 +1,16 @@ +from gratipay import wireup + +db = wireup.db(wireup.env()) + +participants = db.all(""" + SELECT p.*::participants + FROM participants p + JOIN payment_instructions pi ON pi.participant = p.username -- Only include those with tips +""") +total = len(participants) +counter = 0 + +for p in participants: + print("Participant %s/%s" % (counter, total)) + p.update_giving_and_teams() + counter += 1