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
Cap unfunded dues #3876
Closed
+45
−2
Closed
Cap unfunded dues #3876
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
78a3347
Failing test for keeping dues under minimum charge
rohitpaulk 37c8e4f
Prevent dues from exceeding minimum_charge in payday
rohitpaulk 50318f9
Add SQL script to bring all existing unfunded dues to below minimum c…
rohitpaulk 05c0355
Add script to recalculate stale cached values
rohitpaulk 55ce4b2
Correct the payin minimum
chadwhitacre b319262
Store minimum_charge in the database
chadwhitacre 354ede6
Refresh settings after each test
rohitpaulk 8ea83a8
Tinker with how we manage the settings table
chadwhitacre 295cef5
Check has_credit_card instead of minimum_charge
chadwhitacre ac20404
Remove settings table
chadwhitacre ab9df0e
Modify db repair to harmonize w/ new condition
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,16 @@ | ||
from gratipay import wireup | ||
|
||
db = wireup.db(wireup.env()) | ||
|
||
participants = db.all(""" | ||
SELECT p.*::participants | ||
FROM participants p | ||
JOIN payment_instructions pi ON pi.participant = p.username -- Only include those with tips | ||
""") | ||
total = len(participants) | ||
counter = 0 | ||
|
||
for p in participants: | ||
print("Participant %s/%s" % (counter, total)) | ||
p.update_giving_and_teams() | ||
counter += 1 |
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,3 @@ | ||
BEGIN; | ||
UPDATE payment_instructions SET due = 0 WHERE due > 9.41; | ||
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. We could do something like this instead: BEGIN;
CREATE TEMP TABLE _participants AS
SELECT id
, username
, ( SELECT count(*)
FROM current_exchange_routes r
WHERE r.participant = p.id
AND network = 'braintree-cc'
AND error = ''
) > 0 AS has_credit_card
FROM participants p;
UPDATE payment_instructions SET due = 0 WHERE due >= 9.41 AND participant IN (
SELECT username FROM _participants WHERE NOT has_credit_card
);
DROP TABLE _participants;
END; 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. I'm outta time to work on this today, though. I will try to pick up again tomorrow, @rohitpaulk. |
||
END; |
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
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
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.
I would expect this script to run for a few minutes, anyway.
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.
Yes, and I think that's fine - the operations are idempotent so crash/rerun shouldn't be a problem.