@@ -23,6 +23,7 @@ import (
23
23
"github.com/muktihari/fit/profile/basetype"
24
24
"github.com/muktihari/fit/profile/mesgdef"
25
25
"github.com/muktihari/fit/profile/typedef"
26
+ "github.com/openivity/activity-service/aggregator"
26
27
"github.com/openivity/activity-service/strutils"
27
28
)
28
29
@@ -183,31 +184,7 @@ func NewLapFromRecords(records []Record, sport typedef.Sport) Lap {
183
184
// NewLapFromSession creates new lap from a session.
184
185
func NewLapFromSession (session * Session ) Lap {
185
186
lap := CreateLap (nil )
186
-
187
- lap .Sport = session .Sport
188
- lap .SubSport = session .SubSport
189
- lap .Timestamp = session .Timestamp
190
- lap .StartTime = session .StartTime
191
- lap .TotalMovingTime = session .TotalMovingTime
192
- lap .TotalElapsedTime = session .TotalElapsedTime
193
- lap .TotalTimerTime = session .TotalTimerTime
194
- lap .TotalDistance = session .TotalDistance
195
- lap .TotalAscent = session .TotalAscent
196
- lap .TotalDescent = session .TotalDescent
197
- lap .TotalCalories = session .TotalCalories
198
- lap .AvgSpeed = session .AvgSpeed
199
- lap .MaxSpeed = session .MaxSpeed
200
- lap .AvgHeartRate = session .AvgHeartRate
201
- lap .MaxHeartRate = session .MaxHeartRate
202
- lap .AvgCadence = session .AvgCadence
203
- lap .MaxCadence = session .MaxCadence
204
- lap .AvgPower = session .AvgPower
205
- lap .MaxPower = session .MaxPower
206
- lap .AvgTemperature = session .AvgTemperature
207
- lap .MaxTemperature = session .MaxTemperature
208
- lap .AvgAltitude = session .AvgAltitude
209
- lap .MaxAltitude = session .MaxAltitude
210
-
187
+ aggregator .Replace (lap .Lap , session .Session )
211
188
return lap
212
189
}
213
190
@@ -216,74 +193,6 @@ func (l *Lap) IsBelongToThisLap(t time.Time) bool {
216
193
return isBelong (t , l .StartTime , l .EndTime ())
217
194
}
218
195
219
- // ReplaceValues replaces values with the corresponding values in the given lap.
220
- func (l * Lap ) ReplaceValues (lap * Lap ) {
221
- if l == nil || lap == nil {
222
- return
223
- }
224
-
225
- if ! lap .StartTime .IsZero () {
226
- l .StartTime = lap .StartTime
227
- }
228
- if lap .TotalElapsedTime != basetype .Uint32Invalid {
229
- l .TotalElapsedTime = lap .TotalElapsedTime
230
- }
231
- if lap .TotalMovingTime != basetype .Uint32Invalid {
232
- l .TotalMovingTime = lap .TotalMovingTime
233
- }
234
- if lap .TotalTimerTime != basetype .Uint32Invalid {
235
- l .TotalTimerTime = lap .TotalTimerTime
236
- }
237
- if lap .TotalDistance != basetype .Uint32Invalid {
238
- l .TotalDistance = lap .TotalDistance
239
- }
240
- if lap .TotalCalories != basetype .Uint16Invalid {
241
- l .TotalCalories = lap .TotalCalories
242
- }
243
- if lap .TotalAscent != basetype .Uint16Invalid {
244
- l .TotalAscent = lap .TotalAscent
245
- }
246
- if lap .TotalDescent != basetype .Uint16Invalid {
247
- l .TotalDescent = lap .TotalDescent
248
- }
249
- if lap .AvgSpeed != basetype .Uint16Invalid {
250
- l .AvgSpeed = lap .AvgSpeed
251
- }
252
- if lap .MaxSpeed != basetype .Uint16Invalid {
253
- l .MaxSpeed = lap .MaxSpeed
254
- }
255
- if lap .AvgHeartRate != basetype .Uint8Invalid {
256
- l .AvgHeartRate = lap .AvgHeartRate
257
- }
258
- if lap .MaxHeartRate != basetype .Uint8Invalid {
259
- l .MaxHeartRate = lap .MaxHeartRate
260
- }
261
- if lap .AvgCadence != basetype .Uint8Invalid {
262
- l .AvgCadence = lap .AvgCadence
263
- }
264
- if lap .MaxCadence != basetype .Uint8Invalid {
265
- l .MaxCadence = lap .MaxCadence
266
- }
267
- if lap .AvgPower != basetype .Uint16Invalid {
268
- l .AvgPower = lap .AvgPower
269
- }
270
- if lap .MaxPower != basetype .Uint16Invalid {
271
- l .MaxPower = lap .MaxPower
272
- }
273
- if lap .AvgTemperature != basetype .Sint8Invalid {
274
- l .AvgTemperature = lap .AvgTemperature
275
- }
276
- if lap .MaxTemperature != basetype .Sint8Invalid {
277
- l .MaxTemperature = lap .MaxTemperature
278
- }
279
- if lap .AvgAltitude != basetype .Uint16Invalid {
280
- l .AvgAltitude = lap .AvgAltitude
281
- }
282
- if lap .MaxAltitude != basetype .Uint16Invalid {
283
- l .MaxAltitude = lap .MaxAltitude
284
- }
285
- }
286
-
287
196
// MarshalAppendJSON appends the JSON format encoding of Lap to b, returning the result.
288
197
func (l * Lap ) MarshalAppendJSON (b []byte ) []byte {
289
198
b = append (b , '{' )
0 commit comments