Skip to content

Instantly share code, notes, and snippets.

@chadwhitacre
Created July 27, 2012 22:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chadwhitacre/3190854 to your computer and use it in GitHub Desktop.
Save chadwhitacre/3190854 to your computer and use it in GitHub Desktop.
This is the script I used to repair Gittip.com issue #202
#!/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