Skip to content

Commit 6cfab1b

Browse files
committed
track self eval feel and effort ratings
1 parent 89a253c commit 6cfab1b

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

garmindb/garmin_json_data.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,10 @@ def _activities_process_json(self, json_data):
294294
summary_dto = json_data['summaryDTO']
295295
sport, sub_sport = get_details_sport(json_data)
296296
activity = {
297-
'activity_id' : activity_id,
298-
'course_id' : self._get_field(metadata_dto, 'associatedCourseId', int)
297+
'activity_id' : activity_id,
298+
'course_id' : self._get_field(metadata_dto, 'associatedCourseId', int),
299+
'self_eval_feel' : self._get_field(summary_dto, 'directWorkoutFeel', int),
300+
'self_eval_effort' : self._get_field(summary_dto, 'directWorkoutRpe', int)
299301
}
300302
activity.update(self._process_common(summary_dto))
301303
Activities.s_insert_or_update(self.garmin_act_db_session, activity, ignore_none=True)

garmindb/garmindb/activities_db.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class Activities(ActivitiesDb.Base, ActivitiesCommon):
9898
__tablename__ = 'activities'
9999

100100
db = ActivitiesDb
101-
table_version = 4
101+
table_version = 5
102102

103103
activity_id = Column(String, primary_key=True)
104104
name = Column(String)
@@ -109,13 +109,33 @@ class Activities(ActivitiesDb.Base, ActivitiesCommon):
109109
sport = Column(String)
110110
sub_sport = Column(String)
111111

112+
self_eval_feel = Column(Integer)
113+
self_eval_effort = Column(Integer)
114+
112115
training_effect = Column(Float)
113116
anaerobic_training_effect = Column(Float)
114117

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

122+
def get_self_eval_feel(self):
123+
"""Return the Garmin Connect self evaluation 'How did you feel' label for the activity."""
124+
levels = [(100, "Very Strong"), (75, "Strong"), (50, "Normal"), (25, "Weak"), (0, "Very Weak")]
125+
for threshold, label in levels:
126+
print(f"Threshold {threshold} label {label}")
127+
if self.self_eval_feel >= threshold:
128+
return label
129+
130+
def get_self_eval_effort(self):
131+
"""Return the Garmin Connect self evaluation perceived effort label for the activity."""
132+
levels = [(100, "Maximum"), (90, "Extremely Hard"), (70, "Very Hard"), (50, "Hard"),
133+
(40, "Somewhat Hard"), (30, "Moderate"), (20, "Light"), (10, "Very Light"), (0, "None")]
134+
for threshold, label in levels:
135+
print(f"Threshold {threshold} label {label}")
136+
if self.self_eval_effort >= threshold:
137+
return label
138+
119139
@classmethod
120140
def get_by_course_id(cls, db, course_id):
121141
"""Return all activities items for activities with the matching course_id."""

0 commit comments

Comments
 (0)