diff --git a/src/wasm/activity-service/aggregator/aggregator.go b/src/wasm/activity-service/aggregator/aggregator.go index cb67dc3..32e4e02 100644 --- a/src/wasm/activity-service/aggregator/aggregator.go +++ b/src/wasm/activity-service/aggregator/aggregator.go @@ -53,12 +53,12 @@ func Aggregate(dst, src interface{}) { sum(dv.Field(i), sField) // TotalElapsedTime, TotalCycles, etc. case strings.HasPrefix(f.Name, "Num") && strings.HasSuffix(f.Name, "s"): sum(dv.Field(i), sField) // NumSessions, NumLaps, NumSplits, etc. - case strings.HasPrefix(f.Name, "Max"): - max(dv.Field(i), sField) // MaxHeartRate, MaxCadence, etc. - case strings.HasPrefix(f.Name, "Min"): - min(dv.Field(i), sField) // MinHeartRate, MinCadence, etc. - case strings.HasPrefix(f.Name, "Avg"): - avg(dv.Field(i), sField) // AvgHeartRate, AvgCadence, etc. + case strings.HasPrefix(f.Name, "Max") || strings.HasPrefix(f.Name, "EnhancedMax"): + max(dv.Field(i), sField) // MaxHeartRate, MaxCadence, EnhancedMaxRespirationRate, etc. + case strings.HasPrefix(f.Name, "Min") || strings.HasPrefix(f.Name, "EnhancedMin"): + min(dv.Field(i), sField) // MinHeartRate, MinCadence, EnhancedAltitude etc. + case strings.HasPrefix(f.Name, "Avg") || strings.HasPrefix(f.Name, "EnhancedAvg"): + avg(dv.Field(i), sField) // AvgHeartRate, AvgCadence, EnhancedAvgSpeed etc. default: fill(dv.Field(i), sField) // Timestamp, Sport, Event, etc. } diff --git a/src/wasm/activity-service/aggregator/aggregator_test.go b/src/wasm/activity-service/aggregator/aggregator_test.go index 97cb754..36b6582 100644 --- a/src/wasm/activity-service/aggregator/aggregator_test.go +++ b/src/wasm/activity-service/aggregator/aggregator_test.go @@ -52,18 +52,36 @@ func TestAggregate(t *testing.T) { src: mesgdef.NewSession(nil).SetMaxAltitude(2000), exp: mesgdef.NewSession(nil).SetMaxAltitude(2000), }, + { + name: "EnhancedMax", + dst: mesgdef.NewSession(nil).SetEnhancedMaxAltitude(1000), + src: mesgdef.NewSession(nil).SetEnhancedMaxAltitude(2000), + exp: mesgdef.NewSession(nil).SetEnhancedMaxAltitude(2000), + }, { name: "Min", dst: mesgdef.NewSession(nil).SetMinHeartRate(60), src: mesgdef.NewSession(nil).SetMinHeartRate(80), exp: mesgdef.NewSession(nil).SetMinHeartRate(60), }, + { + name: "EnhancedMin", + dst: mesgdef.NewSession(nil).SetEnhancedMinAltitude(60), + src: mesgdef.NewSession(nil).SetEnhancedMinAltitude(80), + exp: mesgdef.NewSession(nil).SetEnhancedMinAltitude(60), + }, { name: "Avg", dst: mesgdef.NewSession(nil).SetAvgTemperature(20), src: mesgdef.NewSession(nil).SetAvgTemperature(22), exp: mesgdef.NewSession(nil).SetAvgTemperature(21), }, + { + name: "EnhancedAvg", + dst: mesgdef.NewSession(nil).SetEnhancedAvgAltitude(60), + src: mesgdef.NewSession(nil).SetEnhancedAvgAltitude(80), + exp: mesgdef.NewSession(nil).SetEnhancedAvgAltitude(70), + }, { name: "Fill dst invalid", dst: mesgdef.NewSession(nil),