-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add level and level_progress to stats api routes #648
base: master
Are you sure you want to change the base?
Conversation
for more information, see https://pre-commit.ci
I'm not sure whether this is a concern for bpy or whether a frontend should implement this itself |
level is a statistic so i don't have an issue with this being provided via API |
tbh would be cooler if level and level progress would be combined |
for more information, see https://pre-commit.ci
i'm not convinced we need all 3. level being a float with the decimals being the progress should be enough i don't particularly care which we pick, but either have level and progress separated or have them combined into one float. but not both |
then i would say keep level and level progress, bc for frotend dev its easier to use the values |
for more information, see https://pre-commit.ci
] | ||
|
||
|
||
def get_required_score_for_level(level: int) -> int: |
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 am ..not sure how i feel about functions living in constants?
|
||
|
||
def get_level_precise(score: int) -> float: | ||
baseLevel = get_level(score) |
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.
baseLevel = get_level(score) | |
base_level = get_level(score) |
etc, use pep8 naming please
@@ -108,6 +110,13 @@ async def get_player_mode_stats( | |||
) | |||
|
|||
response = PlayerStats.from_mapping(data) |
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.
add level and level_progress to data instead. this will cause issues when instantiated otherwise as pydantic will not be happy about these values missing
# NOTE: kinda cursed, but that should do it | ||
response.level = get_level(int(data["tscore"])) | ||
response.level_progress = int( | ||
(get_level_precise(data["tscore"]) - get_level(data["tscore"])) * 100, |
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.
this specific pattern seems to repeat itself quite a lot. could we have a function that returns a tuple of level and level_progress instead and use that where needed?
if score >= LEVEL_GRAPH[99]: | ||
return 100 + int((score - LEVEL_GRAPH[99]) / 100000000000) | ||
|
||
for idx, v in enumerate(LEVEL_GRAPH, start=0): |
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.
you probably want bisect.bisect_left(LEVEL_GRAPH, score)
instead
Describe your changes
Checklist