Skip to content

Commit

Permalink
track self eval feel and effort ratings
Browse files Browse the repository at this point in the history
  • Loading branch information
tcgoetz committed Feb 17, 2024
1 parent 89a253c commit 6cfab1b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
6 changes: 4 additions & 2 deletions garmindb/garmin_json_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,10 @@ def _activities_process_json(self, json_data):
summary_dto = json_data['summaryDTO']
sport, sub_sport = get_details_sport(json_data)
activity = {
'activity_id' : activity_id,
'course_id' : self._get_field(metadata_dto, 'associatedCourseId', int)
'activity_id' : activity_id,
'course_id' : self._get_field(metadata_dto, 'associatedCourseId', int),
'self_eval_feel' : self._get_field(summary_dto, 'directWorkoutFeel', int),
'self_eval_effort' : self._get_field(summary_dto, 'directWorkoutRpe', int)
}
activity.update(self._process_common(summary_dto))
Activities.s_insert_or_update(self.garmin_act_db_session, activity, ignore_none=True)
Expand Down
22 changes: 21 additions & 1 deletion garmindb/garmindb/activities_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class Activities(ActivitiesDb.Base, ActivitiesCommon):
__tablename__ = 'activities'

db = ActivitiesDb
table_version = 4
table_version = 5

activity_id = Column(String, primary_key=True)
name = Column(String)
Expand All @@ -109,13 +109,33 @@ class Activities(ActivitiesDb.Base, ActivitiesCommon):
sport = Column(String)
sub_sport = Column(String)

self_eval_feel = Column(Integer)
self_eval_effort = Column(Integer)

training_effect = Column(Float)
anaerobic_training_effect = Column(Float)

def is_steps_activity(self):
"""Return if the activity is a steps based activity."""
return self.sport in ['walking', 'running', 'hiking']

def get_self_eval_feel(self):
"""Return the Garmin Connect self evaluation 'How did you feel' label for the activity."""
levels = [(100, "Very Strong"), (75, "Strong"), (50, "Normal"), (25, "Weak"), (0, "Very Weak")]
for threshold, label in levels:
print(f"Threshold {threshold} label {label}")
if self.self_eval_feel >= threshold:
return label

def get_self_eval_effort(self):
"""Return the Garmin Connect self evaluation perceived effort label for the activity."""
levels = [(100, "Maximum"), (90, "Extremely Hard"), (70, "Very Hard"), (50, "Hard"),
(40, "Somewhat Hard"), (30, "Moderate"), (20, "Light"), (10, "Very Light"), (0, "None")]
for threshold, label in levels:
print(f"Threshold {threshold} label {label}")
if self.self_eval_effort >= threshold:
return label

@classmethod
def get_by_course_id(cls, db, course_id):
"""Return all activities items for activities with the matching course_id."""
Expand Down

0 comments on commit 6cfab1b

Please sign in to comment.