Skip to content
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

Dynamic measurements #1560

Open
rolandgeider opened this issue Jan 20, 2024 · 3 comments
Open

Dynamic measurements #1560

rolandgeider opened this issue Jan 20, 2024 · 3 comments

Comments

@rolandgeider
Copy link
Member

Add the possibility to create dynamic measurements that are calcualted based on other entries. For example, a 1RM calculated value for squats from the logged values or the BMI.

How exactly this would be configured needs to be discussed first, config file, small python module, etc. since we might want some logic there (in the 1RM example, we might only want to take into account sets with 5 reps or less, or just take the entry with the highest weight for a specific day)

@adrianlzt
Copy link

adrianlzt commented Jan 21, 2024

First POC:
https://github.com/adrianlzt/wger/tree/feature/dynamic_measurements
https://github.com/adrianlzt/wger-react/tree/feature/dynamic_measurements

Add a new field to the category to be able to insert python code. That python code is executed in a limited python interpreter in the backend. The example python code attached to the editor as a snippet calculate a new measurement based on another measurement and the weight of that they.

dynamic_exercises-2024-01-21_19.46.16.mp4

@rolandgeider
Copy link
Member Author

oh, this is nice! Hadn't heard of RestrictedPython before. I also like that we can just define some helper functions like "get_weight_by_date" that would then just be available (but we need to be careful and make sure that we only retrieve the user's data, right now we return any weight entry for that day, but it's just a proof of concept, so it's ok)

@rolandgeider
Copy link
Member Author

rolandgeider commented Jan 23, 2024

We could also think about saving a couple that most people would find useful and allow the users to just select it (like BMI, 1RM for the big three, etc)

BMI = m / height^2 where m is the mass in kg and the height in cm
For the 1RM formula, there are a couple: https://en.wikipedia.org/wiki/One-repetition_maximum

We should also cache the results since depending on what we do, we might have to hit the DB a lot. We can either indefinitely cache this till a new entry is saved or add a new (long lived key) similar to EXERCISE_CACHE_TTL. We can simply cache the whole response like in ExerciseBaseInfoSerializer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants