Skip to content

Commit

Permalink
WIP on basic coding
Browse files Browse the repository at this point in the history
  • Loading branch information
NiharGharat committed May 10, 2023
1 parent eef6fd8 commit c895802
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 27 deletions.
58 changes: 48 additions & 10 deletions src/Entities.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
from typing import List
import datetime
import Utility
import Entities

# The entity which is stored in the csv file
class Exercise:

def __init__(self, id: int, name: str, muscles_targeted: str, calories_10_min: float, fun_factor: int, is_compound: bool, how_critical: int, exercise_type: str) -> None:
def __init__(self, id: int, name: str, muscles_targeted: str, calories_10_min: float, fun_factor: int, is_compound: int, how_critical: int, exercise_type: str) -> None:
self.id: int = id
self.name: str = name
self.exercise_type: str = exercise_type
# bicep tricep legs -> Space sepearted muscle groups
self.muscles_targeted: str = muscles_targeted
self.calories_10_min: float = calories_10_min
self.fun_factor: int = fun_factor
self.is_compound: bool = is_compound
self.is_compound: int = is_compound
self.how_critical: int = how_critical

# The entity which is stored in the csv file
class Workout:

def __init__(self, id: int, date: str, exercise_list: str, workout_fun_factor: int, duration: float, calories_burnt: float, mood: int, activeness: int) -> None:
def __init__(self, id: int, date: str, exercise_list: str, workout_fun_factor: int, duration: float, calories_burnt: float, mood: int, activeness: int, rpe_list: str) -> None:
self.id: int = id
self.date: str = date
# bicep_curl tricep_extension
Expand All @@ -28,12 +30,48 @@ def __init__(self, id: int, date: str, exercise_list: str, workout_fun_factor: i
self.calories_burnt: float = calories_burnt
self.mood: int = mood
self.activeness: int = activeness
# 0 10 7 1 2
# Same order in which user did the exercises
self.rpe_list: str = rpe_list

@staticmethod
def convert_workouts_to_entity(todays_workout: List[str], workout_fun_factor: int, duration: float, calories_burnt: float, mood: int, activeness: int) -> Workout:
now = datetime.now()
# 20230509002049
now_id = int(now.strftime('%Y%m%d%H%M%S'))
now_date = now.strftime('%Y%m%d')
workout = Workout(now_id, now_date, todays_workout, workout_fun_factor, duration, calories_burnt, mood, activeness)
return workout
def prompt_to_create_workout(now) -> Entities.Workout:
id = Utility.get_a_unique_id(now)
# Eg - bicep_curl tricep_extension leg_press
exercise_list: str = input('Enter exercises of a list separated by space ')
date: str = Utility.get_todays_date_in_str(now)
workout_fun_factor: int = int(input('Enter workout fun factor \t\t int \t\t 0 to 5, with 0 being least fun'))
duration: float = float(input('Enter your duration of workout \t\t float'))
calories_burnt: float = input('Enter calories burnt today \t\t float')
mood: int = int(input('Enter your mood today \t\t int \t\t 0 being unhappy'))
activeness = int(input('Enter how active you feel \t\t int \t\t 0 being least active'))
rpe_list: str = input('Enter rpe in int per exercise seperated by space')
# Validation and cleanup of the data entered by the user
# TODO
# Lower case every execrise

todays_workout = Entities.Workout(id, date, exercise_list, workout_fun_factor, duration, calories_burnt, mood, activeness, rpe_list)
return todays_workout

# A class that has the metrics derived from todays workout
class Exercise_Derived:

def __init__(self, id, name, exercise_importance, exercise_cost, exercise_recurrance_factor_per_cycle, exercise_rpe, exercise_overall_fun_factor, exercise_exhaustion_factor, missed_in_cycle_count) -> None:
self.id: int = id
self.name: str = name
self.exercise_importance: int = exercise_importance
self.exercise_cost: int = exercise_cost
self.exercise_recurrance_factor_per_cycle: int = exercise_recurrance_factor_per_cycle
self.exercise_rpe: int = exercise_rpe
self.exercise_overall_fun_factor: int = exercise_overall_fun_factor
self.exercise_exhaustion_factor: int = exercise_exhaustion_factor
self.missed_in_cycle_count: int = missed_in_cycle_count

# @staticmethod
# def convert_workouts_to_entity(todays_workout: List[str], workout_fun_factor: int, duration: float, calories_burnt: float, mood: int, activeness: int) -> Workout:
# now = datetime.now()
# # 20230509002049
# now_id = int(now.strftime('%Y%m%d%H%M%S'))
# now_date = now.strftime('%Y%m%d')
# workout = Workout(now_id, now_date, todays_workout, workout_fun_factor, duration, calories_burnt, mood, activeness)
# return workout
2 changes: 2 additions & 0 deletions src/Enums.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# TODO
# Make a master list of enums which are used in the data files
7 changes: 4 additions & 3 deletions src/ServiceLayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ def __init__(self) -> None:
def save_workouts(self, todays_workout: Entities.Workout) -> bool:
status_of_save: bool = self.dao_layer.save_workout(todays_workout)
# A new workout was just in, need to run recomputations on exercise and workout calc file
status_of_recomputation = self.do_recomputation(todays_workout)
# todays_workout is not needed further as we have already
status_of_recomputation = self.do_recomputation()
return status_of_save and status_of_recomputation

'''
The recomputations
'''
def do_recomputation(self, todays_workout: Entities. Workout):
def do_recomputation(self):
# Do recomputations on exercise_calc
self.recommender_layer.recompute_exercises_weights(todays_workout)
self.recommender_layer.recompute_exercises_weights()
# Do recomputations on workout_calc
self.recommender_layer.recompute_workout_weights()
return None
Expand Down
1 change: 0 additions & 1 deletion src/ServiceLayerDao.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ def _append_workout_to_csv(self, workout: Workout, filename: str):
workout.mood,
workout.activeness
])

return True
14 changes: 1 addition & 13 deletions src/ServiceLayerFrontEnd.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,7 @@ def __init__(self, safety: True) -> None:
'''
def _prompt_user_and_get_todays_workout(self) -> Entities.Workout:
now = datetime.now()

id = Utility.get_a_unique_id(now)
exercise_list: str = input('Enter exercises of a list separated by space ')
date: str = Utility.get_todays_date_in_str(now)
workout_fun_factor: int = int(input('Enter workout fun factor \t\t int \t\t 0 to 5, with 0 being least fun'))
duration: float = float(input('Enter your duration of workout \t\t float'))
calories_burnt: float = input('Enter calories burnt today \t\t float')
mood: int = int(input('Enter your mood today \t\t int \t\t 0 being unhappy'))
activeness = int(input('Enter how active you feel \t\t int \t\t 0 being least active'))

todays_workout = Entities.Workout(id, date, exercise_list, workout_fun_factor, duration, calories_burnt, mood, activeness)
print("\n")
# Eg - bicep_curl tricep_extension leg_press
todays_workout = Entities.Workout.prompt_to_create_workout(now)
return todays_workout

def _main_procedure(self) -> str:
Expand Down
12 changes: 12 additions & 0 deletions src/ServiceLayerRecommender.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
import Entities

class RecommenderLayer:

def __init__(self) -> None:
pass

def recompute_exercises_weights(self, todays_workout: Entities.Workout):
# Here, we need to recompute the weights from the exercise data(in exercise_recomp)

'''
Algo-
1. Read the exercises table
2. Read the workouts table
3.
'''

def recommend_next_workout(self) -> None:
# Pull params from the calc_tables
# Check if the model needs to be trained
Expand Down

0 comments on commit c895802

Please sign in to comment.