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

Commit

Permalink
Fix balanced href fixes #2085
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitpaulk committed Mar 25, 2015
1 parent 836b942 commit 2c2d2f6
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions sql/branch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import balanced

from gratipay import wireup

env = wireup.env()
db = wireup.db(env)
wireup.billing(env)

with db.get_cursor() as cursor:
def update_balanced_href(id, href):
cursor.run("""
UPDATE participants
SET balanced_customer_href=%s
WHERE id=%s
""", (href, id))

participants = cursor.all("""
SELECT id, balanced_customer_href
FROM participants
WHERE balanced_customer_href NOT LIKE '/customers/%';
""")

total = len(participants)
counter = 0

for p in participants:
counter += 1
if counter % 10 == 1:
print "processing participant %i/%i" % (counter, total)
customer = balanced.Customer.fetch(p.balanced_customer_href)
update_balanced_href(p.id, customer.href)

0 comments on commit 2c2d2f6

Please sign in to comment.