timetable-mgr/src/corpus/update.go

40 lines
945 B
Go
Raw Normal View History

2024-03-26 15:40:15 +00:00
package corpus
import (
"fmt"
"git.fjla.uk/owlboard/timetable-mgr/helpers"
"git.fjla.uk/owlboard/timetable-mgr/log"
"go.uber.org/zap"
)
func RunCorpusUpdate(cfg *helpers.Configuration) {
resp, err := fetchCorpus(cfg)
if err != nil {
log.Msg.Error("Failed to update Corpus data", zap.Error(err))
}
datastring, err := extractCorpusResponse(resp)
if err != nil {
log.Msg.Error("Error extracting Corpus data", zap.Error(err))
}
2024-03-26 16:04:42 +00:00
unsortedCorpusData, err := parseCorpusData(datastring)
2024-03-26 15:40:15 +00:00
if err != nil {
log.Msg.Error("Error parsing Corpus data", zap.Error(err))
}
2024-03-26 16:04:42 +00:00
corpusData := pruneCorpusEntries(unsortedCorpusData)
stationData := createStationEntries(corpusData)
2024-03-26 15:40:15 +00:00
2024-03-26 16:04:42 +00:00
for _, entry := range corpusData {
2024-03-26 15:40:15 +00:00
fmt.Printf("DESC: %s, NLC: %d, CRS: '%s'\n",
entry.NLCDESC, entry.NLC, entry.CRS)
}
2024-03-26 16:04:42 +00:00
for _, entry := range stationData {
fmt.Printf("NAME: %s, CRS: %s, TIPLOC: %s\n",
entry.NLCDESC, entry.CRS, entry.TIPLOC)
}
2024-03-26 15:40:15 +00:00
}