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 308
sync our database with braintree #3473
Closed
Closed
Changes from 4 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
b20ecb2
Start files for syncing with braintree
chadwhitacre 5300db6
We already have braintree_customer_id
chadwhitacre dd0c890
Shelve work on migration script
chadwhitacre f32b1ed
First draft of sync script
chadwhitacre 67c3b34
Update script to skip some participants
chadwhitacre 0b5a4a6
pyflakes
chadwhitacre eb22015
Free up stdin for heroku config
chadwhitacre 8c34500
Tweak the logic a bit
chadwhitacre 631d8cd
Here's a script for finding removed cards
chadwhitacre 2d5ce74
Start another script for iterating over Braintree
chadwhitacre 94f09fc
Count orphans and early adopters
chadwhitacre e5bf6b1
Implement threaded_map over card_ids
chadwhitacre 0cc4896
Implement participant syncing
chadwhitacre 9b39bff
Improve logging a bit
chadwhitacre fa9525e
See if we can recover any of the orphans
chadwhitacre b34b3b6
Blip
chadwhitacre 4c02e13
All systems go!
chadwhitacre 4481b8d
Work around non-idempotency
chadwhitacre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ | ||
#!/usr/bin/env python | ||
from __future__ import print_function | ||
|
||
import csv | ||
import sys | ||
from gratipay.wireup import db, env | ||
from gratipay.models.exchange_route import ExchangeRoute | ||
|
||
|
||
DETAILS = 4 | ||
NAME = 7 | ||
CUSTOMER_ID = 1 | ||
CARD_ID = -1 | ||
CHECK = 6 | ||
db = db(env()) | ||
|
||
for row in csv.reader(sys.stdin): | ||
if row[DETAILS] != 'customer': | ||
continue | ||
assert row[CUSTOMER_ID] == row[CHECK], row | ||
|
||
customer_id = row[CUSTOMER_ID] | ||
card_id = row[CARD_ID] | ||
|
||
p = db.one( "SELECT p.*::participants FROM participants p WHERE balanced_customer_href=%s" | ||
, ("/customers/{}".format(customer_id),) | ||
) | ||
|
||
er = ExchangeRoute.insert(p, 'braintree-cc', card_id) | ||
db.run("UPDATE participants SET braintree_customer_id=%s", (customer_id,)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ;-) Still commented out tbh. |
||
|
||
print("{} -> {} ({}) {}".format(p.balanced_customer_href, customer_id, card_id, p.username)) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before we do this, we should check whether a route exists for
braintree-cc
. If so, the user had updated his card, and we should just leave the participant as is.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay.