|
|
|
@ -2,7 +2,6 @@ package cif
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"strconv"
|
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
"git.fjla.uk/owlboard/go-types/pkg/database"
|
|
|
|
|
"git.fjla.uk/owlboard/go-types/pkg/upstreamApi"
|
|
|
|
@ -22,7 +21,7 @@ func ConvertServiceType(input *upstreamApi.JsonScheduleV1, vstp bool) (*database
|
|
|
|
|
PlanSpeed: parseSpeed(&input.ScheduleSegment.CifSpeed),
|
|
|
|
|
ScheduleStartDate: ParseCifDate(&input.ScheduleStartDate, "start"),
|
|
|
|
|
ScheduleEndDate: ParseCifDate(&input.ScheduleEndDate, "end"),
|
|
|
|
|
ServiceDetail: generateServiceDetail(&input.ScheduleSegment.CifTrainClass, &input.ScheduleSegment.SignallingId, &input.ScheduleSegment.CifCateringCode, &input.ScheduleSegment.CifSleepers, &input.ScheduleSegment.CifOperatingCharacteristics, vstp),
|
|
|
|
|
ServiceDetail: generateServiceDetail(&input.ScheduleSegment.CifTrainClass, &input.ScheduleSegment.SignallingId, &input.ScheduleSegment.CifCateringCode, &input.ScheduleSegment.CifSleepers, vstp),
|
|
|
|
|
DaysRun: parseDaysRun(&input.ScheduleDaysRun),
|
|
|
|
|
Stops: parseStops(&input.ScheduleSegment.ScheduleLocation),
|
|
|
|
|
}
|
|
|
|
@ -86,8 +85,7 @@ func isPublic(input *upstreamApi.CifScheduleLocation) bool {
|
|
|
|
|
// Generates a ServiceDetail struct based on the input
|
|
|
|
|
func generateServiceDetail(
|
|
|
|
|
cifTrainClass, signallingId,
|
|
|
|
|
cateringCode, sleepers,
|
|
|
|
|
operatingCharacteristics *string,
|
|
|
|
|
cateringCode, sleepers *string,
|
|
|
|
|
vstp bool,
|
|
|
|
|
) database.ServiceDetail {
|
|
|
|
|
return database.ServiceDetail{
|
|
|
|
@ -95,7 +93,6 @@ func generateServiceDetail(
|
|
|
|
|
Catering: hasCatering(cateringCode),
|
|
|
|
|
Sleeper: hasSleeper(sleepers),
|
|
|
|
|
Vstp: vstp,
|
|
|
|
|
Guard: hasGuard(operatingCharacteristics),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -129,9 +126,3 @@ func hasSleeper(input *string) bool {
|
|
|
|
|
}
|
|
|
|
|
return *input != ""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ascertains whether the service requires a guard
|
|
|
|
|
func hasGuard(opChars *string) bool {
|
|
|
|
|
str := strings.ToLower(*opChars)
|
|
|
|
|
return strings.Contains(str, "g")
|
|
|
|
|
}
|
|
|
|
|