This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
836b942
commit f52f1c7
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import balanced | ||
from pprint import pprint | ||
|
||
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) |