Skip to content

Commit

Permalink
Release 28-10-2024 (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
muktihari authored Oct 28, 2024
1 parent 3cfdfe9 commit b4f4463
Showing 1 changed file with 8 additions and 21 deletions.
29 changes: 8 additions & 21 deletions src/wasm/activity-service/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,6 @@ func (s *Service) changeSport(activities []activity.Activity, sports []string) {

// trimRecords trims Records based on the markers (1 marker correspond to 1 session) and recalculate the summary since the records is trimmed.
func (s *Service) trimRecords(a *activity.Activity, markers []spec.EncodeMarker) error {
if len(markers) == 0 {
return nil
}
if len(markers) < len(a.Sessions) {
return fmt.Errorf("trim: marker size is less than sessions size")
}
Expand All @@ -496,16 +493,11 @@ func (s *Service) trimRecords(a *activity.Activity, markers []spec.EncodeMarker)
ses := &a.Sessions[i]
marker := markers[i]

if marker.StartN == 0 && marker.EndN == len(ses.Records)-1 { // no data to be trimmed
continue
}

if marker.StartN >= len(ses.Records)-1 {
ses.Records = nil
if marker.StartN == 0 && marker.EndN == len(ses.Records)-1 {
continue
}

if marker.EndN == 0 {
if marker.StartN == marker.EndN {
ses.Records = nil
continue
}
Expand Down Expand Up @@ -580,9 +572,6 @@ func (s *Service) trimRecords(a *activity.Activity, markers []spec.EncodeMarker)

// concealGPSPositions conceal positions from the records by removing PositionLat and PositionLong.
func (s *Service) concealGPSPositions(a *activity.Activity, markers []spec.EncodeMarker) error {
if len(markers) == 0 {
return nil
}
if len(markers) < len(a.Sessions) {
return fmt.Errorf("conceal: marker size is less than sessions size")
}
Expand All @@ -591,19 +580,17 @@ func (s *Service) concealGPSPositions(a *activity.Activity, markers []spec.Encod
ses := a.Sessions[i]
marker := markers[i]

if marker.StartN == 0 && marker.EndN == 0 {
if marker.StartN == 0 && marker.EndN == len(ses.Records)-1 {
continue
}

if marker.StartN >= len(ses.Records)-1 {
marker.StartN = len(ses.Records) - 1
}

if marker.EndN == 0 {
marker.EndN = len(ses.Records) - 1
if marker.StartN == marker.EndN {
marker.StartN++
marker.EndN--
continue
}

for j := 0; j < marker.StartN+1; j++ {
for j := 0; j < marker.StartN; j++ {
ses.Records[j].PositionLat = basetype.Sint32Invalid
ses.Records[j].PositionLong = basetype.Sint32Invalid
}
Expand Down

0 comments on commit b4f4463

Please sign in to comment.