@@ -38,6 +38,11 @@ def write_file(self, fit_file):
38
38
def _plugin_dispatch (self , handler_name , * args , ** kwargs ):
39
39
return super ()._plugin_dispatch (self .monitoring_fit_file_plugins , handler_name , * args , ** kwargs )
40
40
41
+ @classmethod
42
+ def __unpack_tuple (cls , entry , name , value , index ):
43
+ if type (value ) is tuple :
44
+ entry [name ] = value [index ]
45
+
41
46
def _write_monitoring_info_entry (self , fit_file , message_fields ):
42
47
activity_types = message_fields .activity_type
43
48
if isinstance (activity_types , list ):
@@ -46,10 +51,10 @@ def _write_monitoring_info_entry(self, fit_file, message_fields):
46
51
'file_id' : File .s_get_id (self .garmin_db_session , fit_file .filename ),
47
52
'timestamp' : message_fields .local_timestamp ,
48
53
'activity_type' : activity_type ,
49
- 'resting_metabolic_rate' : message_fields .get ('resting_metabolic_rate' ),
50
- 'cycles_to_distance' : message_fields .cycles_to_distance [index ],
51
- 'cycles_to_calories' : message_fields .cycles_to_calories [index ]
54
+ 'resting_metabolic_rate' : message_fields .get ('resting_metabolic_rate' )
52
55
}
56
+ self .__unpack_tuple (entry , 'cycles_to_distance' , message_fields .cycles_to_distance , index )
57
+ self .__unpack_tuple (entry , 'cycles_to_calories' , message_fields .cycles_to_calories , index )
53
58
MonitoringInfo .s_insert_or_update (self .garmin_mon_db_session , entry )
54
59
55
60
def _write_monitoring_entry (self , fit_file , message_fields ):
0 commit comments