Testing new stations data

This commit is contained in:
Fred Boniface
2024-06-30 20:28:34 +01:00
parent 9496c9aae0
commit 77eb22b837
4 changed files with 115 additions and 29 deletions

View File

@@ -1,7 +1,6 @@
package stations
import (
"fmt"
"time"
"git.fjla.uk/owlboard/timetable-mgr/dbAccess"
@@ -33,23 +32,41 @@ func Check() {
func run() bool {
// Download
data, data2, err := download()
log.Info("Downloaded station data from two sources")
if err != nil {
fmt.Println(err)
log.Error("error downloading station data", zap.Error(err))
return false
}
// Parse
stations, err := parseData(data, data2)
log.Info("Parsed station data")
if err != nil {
fmt.Println(err)
log.Error("error parsing station data", zap.Error(err))
return false
}
// Drop
dbAccess.DropCollection("stations")
err = dbAccess.DropCollection("stations")
if err != nil {
log.Error("Error dropping stations collection", zap.Error(err))
}
// Push
dbAccess.PutManyNewStations(&stations)
err = dbAccess.PutManyNewStations(&stations)
if err != nil {
log.Error("Error putting new station data", zap.Error(err))
}
err = dbAccess.CreateStationIndeces()
if err != nil {
log.Error("Error creating station indeces", zap.Error(err))
}
ok := dbAccess.SetStationsMetadata(time.Now())
if !ok {
log.Warn("Error setting new metadata for Stations")
}
return true
}

View File

@@ -29,7 +29,6 @@ func parseData(data ...[]byte) ([]database.Station, error) {
}
output = append(output, outputStation)
}
fmt.Println(output)
return output, nil
}