-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
957a0b7
commit 7b9774d
Showing
12 changed files
with
281 additions
and
8 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
packages/discovery-provider/ddl/migrations/0036_add_challenge_disbursement_cap.sql
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,12 @@ | ||
begin; | ||
|
||
alter table challenge_disbursements | ||
add column created_at timestamp with time zone default now(); | ||
|
||
create index idx_challenge_disbursements_created_at | ||
on challenge_disbursements (created_at); | ||
|
||
alter table challenges | ||
add column weekly_pool integer default null; | ||
|
||
commit; |
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
52 changes: 52 additions & 0 deletions
52
...ages/discovery-provider/integration_tests/queries/test_get_disbursed_challenges_amount.py
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,52 @@ | ||
from datetime import datetime, timedelta | ||
|
||
from integration_tests.utils import populate_mock_db | ||
from src.queries.get_disbursed_challenges_amount import get_disbursed_challenges_amount | ||
from src.utils.db_session import get_db | ||
|
||
|
||
def test_get_disbursed_challenges_amount(app): | ||
with app.app_context(): | ||
db = get_db() | ||
|
||
entities = { | ||
"challenge_disbursements": [ | ||
{ | ||
"challenge_id": "profile-completion", | ||
"specifier": "1", | ||
"user_id": 1, | ||
"amount": "5", | ||
}, | ||
{ | ||
"challenge_id": "profile-completion", | ||
"specifier": "2", | ||
"user_id": 2, | ||
"amount": "10", | ||
}, | ||
{ | ||
"challenge_id": "profile-completion", | ||
"specifier": "3", | ||
"user_id": 3, | ||
"amount": "20", | ||
"created_at": datetime.now() - timedelta(days=8), | ||
}, | ||
{ | ||
"challenge_id": "listen-streak", | ||
"specifier": "1", | ||
"user_id": 1, | ||
"amount": "4", | ||
}, | ||
{ | ||
"challenge_id": "listen-streak", | ||
"specifier": "2", | ||
"user_id": 2, | ||
"amount": "12", | ||
}, | ||
], | ||
} | ||
populate_mock_db(db, entities) | ||
with db.scoped_session() as session: | ||
amount_disbursed = get_disbursed_challenges_amount( | ||
session, "profile-completion", datetime.now() - timedelta(days=7) | ||
) | ||
assert amount_disbursed == 15 |
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
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
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
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
Oops, something went wrong.