Created
July 27, 2012 22:42
-
-
Save chadwhitacre/3190854 to your computer and use it in GitHub Desktop.
This is the script I used to repair Gittip.com issue #202
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
#!/usr/bin/env python | |
from gittip import wireup | |
db = wireup.db() | |
names = open('affected.txt').read().splitlines() | |
for name in names: | |
recs = db.fetchall("select participant_id, amount, fee, timestamp " | |
"from exchanges " | |
"where participant_id=%s " | |
"and timestamp > '2012-07-27' " | |
"order by amount desc", (name,)) | |
recs = list(recs) | |
assert len(recs) == 1 | |
wrong_amount = recs[0]['amount'] | |
print name.ljust(16), wrong_amount | |
db.execute("update exchanges set amount = 9.32, fee = 0.68 " | |
"where participant_id=%s and timestamp > '2012-07-27'", (name,)) | |
db.execute("update participants set balance = balance + (9.32 - %s) " | |
"where id=%s", (wrong_amount, name)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment