Testing new stations data
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ func parseData(data ...[]byte) ([]database.Station, error) {
|
||||
}
|
||||
output = append(output, outputStation)
|
||||
}
|
||||
fmt.Println(output)
|
||||
return output, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user