From 362779f7de6ff0a3f7a1c547a66bda44d7e9b77d Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Thu, 20 Jul 2023 12:01:20 +0100 Subject: [PATCH] Adjust formatting functions --- src/go.mod | 2 +- src/go.sum | 2 ++ src/vstp/parser.go | 14 +++++++------- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/go.mod b/src/go.mod index 4dcd78e..a04332f 100644 --- a/src/go.mod +++ b/src/go.mod @@ -3,7 +3,7 @@ module git.fjla.uk/owlboard/mq-client go 1.19 require ( - git.fjla.uk/owlboard/go-types v0.0.0-20230720095555-ad24002a6acc + git.fjla.uk/owlboard/go-types v0.0.0-20230720100930-1cbfb1d074d2 github.com/go-stomp/stomp/v3 v3.0.5 go.mongodb.org/mongo-driver v1.12.0 go.uber.org/zap v1.24.0 diff --git a/src/go.sum b/src/go.sum index d9289ce..b02f618 100644 --- a/src/go.sum +++ b/src/go.sum @@ -12,6 +12,8 @@ git.fjla.uk/owlboard/go-types v0.0.0-20230719192727-845a41f8572b h1:QKHrP3kjvypP git.fjla.uk/owlboard/go-types v0.0.0-20230719192727-845a41f8572b/go.mod h1:kG+BX9UF+yJaAVnln/QSKlTdrtKRRReezMeSk1ZLMzY= git.fjla.uk/owlboard/go-types v0.0.0-20230720095555-ad24002a6acc h1:7s+svu/FOU/qwLLThtwvOV2CqID8sZmVyd15UldgBR8= git.fjla.uk/owlboard/go-types v0.0.0-20230720095555-ad24002a6acc/go.mod h1:kG+BX9UF+yJaAVnln/QSKlTdrtKRRReezMeSk1ZLMzY= +git.fjla.uk/owlboard/go-types v0.0.0-20230720100930-1cbfb1d074d2 h1:FOLnHCAL/2fnjC/TLpQkt4WSMzijcDrtyf0YdiyZIbo= +git.fjla.uk/owlboard/go-types v0.0.0-20230720100930-1cbfb1d074d2/go.mod h1:kG+BX9UF+yJaAVnln/QSKlTdrtKRRReezMeSk1ZLMzY= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= diff --git a/src/vstp/parser.go b/src/vstp/parser.go index e7fe2a0..c0f8400 100644 --- a/src/vstp/parser.go +++ b/src/vstp/parser.go @@ -18,7 +18,6 @@ func unmarshalData(jsonData string) database.Service { fmt.Println(jsonData) log.Msg.Debug("Converting to byte array") jsonDataBytes := []byte(jsonData) - fmt.Println(jsonDataBytes) var schedule upstreamApi.VstpMsg err := json.Unmarshal(jsonDataBytes, &schedule) if err != nil { @@ -32,19 +31,20 @@ func unmarshalData(jsonData string) database.Service { } // Transforms the upstreamApi.Schedule type into a database.Service type -func formatData(dataInput upstreamApi.Schedule) database.Service { +func formatData(dataInput *upstreamApi.Schedule) database.Service { + log.Msg.Debug("ScheduleSegment length: " + fmt.Sprint(len(dataInput.ScheduleSegment))) service := database.Service{ TransactionType: dataInput.TransactionType, StpIndicator: dataInput.CIFSTPIndicator, - Operator: dataInput.ScheduleSegment.ATOCCode, + Operator: dataInput.ScheduleSegment[0].ATOCCode, TrainUid: dataInput.CIFTrainUID, - Headcode: dataInput.ScheduleSegment.SignallingID, - PowerType: dataInput.ScheduleSegment.CIFPowerType, - PlanSpeed: parseSpeed(dataInput.ScheduleSegment.CIFSpeed), + Headcode: dataInput.ScheduleSegment[0].SignallingID, + PowerType: dataInput.ScheduleSegment[0].CIFPowerType, + PlanSpeed: parseSpeed(dataInput.ScheduleSegment[0].CIFSpeed), ScheduleStartDate: parseDate(dataInput.ScheduleStartDate, false), ScheduleEndDate: parseDate(dataInput.ScheduleEndDate, true), DaysRun: parseDaysRun(dataInput.ScheduleDaysRun), - Stops: parseStops(dataInput.ScheduleSegment.ScheduleLocation), + Stops: parseStops(dataInput.ScheduleSegment[0].ScheduleLocation), } return service }