-
-
Notifications
You must be signed in to change notification settings - Fork 775
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sort collections based on updated shuffle_rank that randomizes sort w…
…hile giving collections with meaningful metadata more of a chance of being shown closer to the top (#9672) Refs: #9614 Co-authored-by: Tim Schultz <[email protected]>
- Loading branch information
Tim Schultz
and
Tim Schultz
authored
Nov 17, 2021
1 parent
28defb1
commit dd5c14b
Showing
4 changed files
with
79 additions
and
2 deletions.
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
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
36 changes: 36 additions & 0 deletions
36
app/grants/tests/management/commands/test_grant_collections_shuffle.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,36 @@ | ||
from datetime import datetime, timedelta | ||
from io import StringIO | ||
|
||
from django.core.management import call_command | ||
|
||
import pytest | ||
from grants.management.commands.grant_collections_shuffle import grant_collection_age_score, grant_meta_data_score | ||
|
||
from ...models.factories.grant_collection_factory import GrantCollectionFactory | ||
from ...models.factories.grant_factory import GrantFactory | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_grant_collections_shuffle_grant_meta_data_score(): | ||
grant_1 = GrantFactory() | ||
grant_2 = GrantFactory() | ||
|
||
grant_1.twitter_verified = True | ||
grant_2.twitter_verified = True | ||
|
||
grant_1.github_project_url = 'https://github.com/gitcoinco/web' | ||
grant_2.github_project_url = 'https://github.com/gitcoinco/web' | ||
|
||
grants = (grant_1, grant_2) | ||
|
||
score = grant_meta_data_score(grants) | ||
|
||
assert score == 12000 | ||
|
||
@pytest.mark.django_db | ||
def test_grant_collections_shuffle_calc_age_score(): | ||
today = datetime.now() | ||
last_month = today - (today - timedelta(days=28)) | ||
last_week = today - timedelta(days=7) | ||
score = grant_collection_age_score(last_month, last_week) | ||
assert score == 3750 |
dd5c14b
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.
closes https://gitcoin.atlassian.net/browse/GITC-512