regular routes journeys, persistent KV to store return states, ...

This commit is contained in:
2023-04-03 20:35:12 +02:00
parent 0ae5730e7f
commit 2f536dfb19
21 changed files with 1722 additions and 1070 deletions

View File

@@ -78,6 +78,8 @@ func (h *CarpoolServiceHandler) GetUserPlanning(userid string, minDepartureDate
return nil, err
}
all_schedules := []internal.PlannedRouteSchedule{}
for _, r := range routes {
rr := internal.RegularRoute(*r)
schedules, err := rr.PlannedJourneySchedules(minDepartureDate, maxDepartureDate)
@@ -86,6 +88,8 @@ func (h *CarpoolServiceHandler) GetUserPlanning(userid string, minDepartureDate
return nil, err
}
all_schedules = append(all_schedules, schedules...)
for _, s := range schedules {
log.Debug().
Str("route id", s.Route.ExtraMembers.MustString("id")).
@@ -97,5 +101,13 @@ func (h *CarpoolServiceHandler) GetUserPlanning(userid string, minDepartureDate
}
}
if len(all_schedules) > 0 {
err = h.Storage.StoreRouteSchedules(all_schedules)
if err != nil {
log.Error().Err(err).Msg("could not store route schedules")
return nil, err
}
}
return results, nil
}