diff --git a/src/cif/check.go b/src/cif/check.go new file mode 100644 index 0000000..68a197d --- /dev/null +++ b/src/cif/check.go @@ -0,0 +1,4 @@ +package cif + +// Check if CIF Data needs updating +// Run update if required diff --git a/src/corpus/check.go b/src/corpus/check.go new file mode 100644 index 0000000..4087156 --- /dev/null +++ b/src/corpus/check.go @@ -0,0 +1,4 @@ +package corpus + +// Check if corpus data needs updating. +// Run update if needed. diff --git a/src/corpus/stations.go b/src/corpus/stations.go new file mode 100644 index 0000000..68adeb5 --- /dev/null +++ b/src/corpus/stations.go @@ -0,0 +1,22 @@ +package corpus + +import "git.fjla.uk/owlboard/go-types/pkg/database" + +func createStationEntries(corpusData []database.CorpusEntry) []database.StationEntry { + var stationEntries []database.StationEntry + + for _, entry := range corpusData { + if entry.CRS != "" { + stationEntry := database.StationEntry{ + CRS: entry.CRS, + TIPLOC: entry.TIPLOC, + NLCDESC: entry.NLCDESC, + STANOX: entry.STANOX, + } + + stationEntries = append(stationEntries, stationEntry) + } + } + + return stationEntries +} diff --git a/src/corpus/update.go b/src/corpus/update.go index d29034c..2607ed4 100644 --- a/src/corpus/update.go +++ b/src/corpus/update.go @@ -19,15 +19,21 @@ func RunCorpusUpdate(cfg *helpers.Configuration) { log.Msg.Error("Error extracting Corpus data", zap.Error(err)) } - corpusData, err := parseCorpusData(datastring) + unsortedCorpusData, err := parseCorpusData(datastring) if err != nil { log.Msg.Error("Error parsing Corpus data", zap.Error(err)) } - prunedCorpusData := pruneCorpusEntries(corpusData) + corpusData := pruneCorpusEntries(unsortedCorpusData) + stationData := createStationEntries(corpusData) - for _, entry := range prunedCorpusData { + for _, entry := range corpusData { fmt.Printf("DESC: %s, NLC: %d, CRS: '%s'\n", entry.NLCDESC, entry.NLC, entry.CRS) } + + for _, entry := range stationData { + fmt.Printf("NAME: %s, CRS: %s, TIPLOC: %s\n", + entry.NLCDESC, entry.CRS, entry.TIPLOC) + } } diff --git a/src/go.mod b/src/go.mod index 2cf663d..6732671 100644 --- a/src/go.mod +++ b/src/go.mod @@ -3,7 +3,7 @@ module git.fjla.uk/owlboard/timetable-mgr go 1.21 require ( - git.fjla.uk/owlboard/go-types v0.0.0-20240326151548-5491671b8bb4 + git.fjla.uk/owlboard/go-types v0.0.0-20240326154559-f85646ac1a58 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 e796a80..50c54e1 100644 --- a/src/go.sum +++ b/src/go.sum @@ -4,6 +4,8 @@ git.fjla.uk/owlboard/go-types v0.0.0-20240326142657-0fc57cb903e6 h1:p3m0gpFqsyBR git.fjla.uk/owlboard/go-types v0.0.0-20240326142657-0fc57cb903e6/go.mod h1:kG+BX9UF+yJaAVnln/QSKlTdrtKRRReezMeSk1ZLMzY= git.fjla.uk/owlboard/go-types v0.0.0-20240326151548-5491671b8bb4 h1:FqDR2uRWVpZjwyEUHrsHSBXcnRgUmoRlF/lGojL7KcE= git.fjla.uk/owlboard/go-types v0.0.0-20240326151548-5491671b8bb4/go.mod h1:kG+BX9UF+yJaAVnln/QSKlTdrtKRRReezMeSk1ZLMzY= +git.fjla.uk/owlboard/go-types v0.0.0-20240326154559-f85646ac1a58 h1:8r1oGpD1yG4Jk9B9vKe2KNbngmbCxP+S3ISNxL/P3xc= +git.fjla.uk/owlboard/go-types v0.0.0-20240326154559-f85646ac1a58/go.mod h1:kG+BX9UF+yJaAVnln/QSKlTdrtKRRReezMeSk1ZLMzY= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=