Fix rer display and add missions
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
nemunaire 2024-07-27 10:37:24 +02:00
parent e648d083f8
commit 9238097b41

View File

@ -79,6 +79,7 @@ type IDFMRealTime struct {
type PGSchedule struct {
Destination string `json:"destination"`
Mission string `json:"mission,omitempty"`
Message string `json:"message"`
}
@ -172,9 +173,19 @@ func declareSchedulesRoutes(router *gin.RouterGroup) {
pgs := []PGSchedule{}
for _, vehicule := range schedules {
msg := vehicule.MonitoredVehicleJourney.MonitoredCall.ExpectedDepartureTime.String()
var msg string
var mission string
if t == "metro" || t == "bus" || t == "noctiliens" || t == "tramway" {
if vehicule.MonitoredVehicleJourney.MonitoredCall.DepartureStatus != "onTime" {
log.Println("DepartureStatus =", vehicule.MonitoredVehicleJourney.MonitoredCall.DepartureStatus)
}
if t == "rail" {
msg = vehicule.MonitoredVehicleJourney.MonitoredCall.ExpectedDepartureTime.Format("15:04")
if len(vehicule.MonitoredVehicleJourney.JourneyNote) > 0 {
mission = vehicule.MonitoredVehicleJourney.JourneyNote[0].Value
}
} else if t == "metro" || t == "bus" || t == "noctiliens" || t == "tramway" {
if vehicule.MonitoredVehicleJourney.MonitoredCall.VehicleAtStop {
if t == "metro" {
msg = "Train à quai"
@ -190,10 +201,13 @@ func declareSchedulesRoutes(router *gin.RouterGroup) {
} else {
msg = fmt.Sprintf("%d mn", int(math.Floor(time.Until(vehicule.MonitoredVehicleJourney.MonitoredCall.ExpectedDepartureTime).Minutes())))
}
} else {
msg = vehicule.MonitoredVehicleJourney.MonitoredCall.ExpectedDepartureTime.String()
}
pgs = append(pgs, PGSchedule{
Destination: vehicule.MonitoredVehicleJourney.MonitoredCall.DestinationDisplay[0].Value,
Mission: mission,
Message: msg,
})
}