forked from RealistikOsu/USSR
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hide custom leaderboard size behind a feature flag (#128)
- Loading branch information
Showing
6 changed files
with
50 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from __future__ import annotations | ||
|
||
import logging | ||
|
||
from amplitude_experiment import Experiment | ||
from amplitude_experiment import User | ||
|
||
import config | ||
|
||
experiment = Experiment.initialize_local(config.AMPLITUDE_DEPLOYMENT_KEY) | ||
|
||
|
||
def is_feature_enabled( | ||
feature_name: str, | ||
*, | ||
user_id: str | None = None, | ||
device_id: str | None = None, | ||
) -> bool: | ||
try: | ||
if not experiment.poller.is_running: | ||
experiment.start() | ||
|
||
if device_id is None and user_id is None: | ||
user_id = "1xx" | ||
|
||
user = User(device_id=device_id, user_id=user_id) # type: ignore[unused-ignore] | ||
variant = experiment.evaluate_v2(user, {feature_name}).get(feature_name) | ||
if variant is None: | ||
return False | ||
|
||
return variant.value == "on" # type: ignore[no-any-return] | ||
except Exception: | ||
logging.exception( | ||
"Failed to retrieve experiment", | ||
extra={"feature_name": feature_name}, | ||
) | ||
return False |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
aio-pika | ||
aiobotocore | ||
amplitude-experiment | ||
bcrypt | ||
cryptography | ||
databases[asyncmy] | ||
|