Compare commits

..

No commits in common. "main" and "2024.11.4" have entirely different histories.

6 changed files with 10 additions and 14 deletions

View File

@ -17,7 +17,7 @@ var MongoClient (*mongo.Client)
// Builds the DB URI based on the loaded configuration parameters // Builds the DB URI based on the loaded configuration parameters
func getDbUri(cfg *helpers.Configuration) string { func getDbUri(cfg *helpers.Configuration) string {
var uri = "mongodb://" + cfg.DbUser + ":" + cfg.DbPass + "@" + cfg.DbHost + ":" + cfg.DbPort + "/?authSource=owlboard" var uri = "mongodb://" + cfg.DbUser + ":" + cfg.DbPass + "@" + cfg.DbHost + ":" + cfg.DbPort
return uri return uri
} }

View File

@ -106,7 +106,7 @@ func GetTiplocFromCrs(crs string) (tiploc string, err error) {
}, },
} }
coll := MongoClient.Database(DatabaseName).Collection(CorpusCollection) coll := MongoClient.Database(DatabaseName).Collection(StationsCollection)
cursor, err := coll.Aggregate(context.Background(), pipeline) cursor, err := coll.Aggregate(context.Background(), pipeline)
if err != nil { if err != nil {
return "", err return "", err
@ -144,7 +144,7 @@ func GetStanoxFromCrs(crs string) (stanox string, err error) {
}, },
} }
coll := MongoClient.Database(DatabaseName).Collection(CorpusCollection) coll := MongoClient.Database(DatabaseName).Collection(StationsCollection)
cursor, err := coll.Aggregate(context.Background(), pipeline) cursor, err := coll.Aggregate(context.Background(), pipeline)
if err != nil { if err != nil {
return "", err return "", err

View File

@ -47,13 +47,13 @@ func PutPisMetadata(version string) error {
return err return err
} }
log.Info("New PIS Metadata written", zap.String("version", version)) log.Info("New Stations Metadata written", zap.String("version", version))
return nil return nil
} }
// Puts complete PIS dataset to database // Puts complete PIS dataset to database
func PutPisData(pis *[]database.PIS) (int64, error) { func PutPisData(pis *[]database.PIS) (int64, error) {
coll := MongoClient.Database(DatabaseName).Collection(PisCollection) coll := MongoClient.Database(DatabaseName).Collection("pis_testing")
var docs []interface{} var docs []interface{}
for _, entry := range *pis { for _, entry := range *pis {
@ -69,7 +69,7 @@ func PutPisData(pis *[]database.PIS) (int64, error) {
} }
func CreatePisIndeces() error { func CreatePisIndeces() error {
coll := MongoClient.Database(DatabaseName).Collection(PisCollection) coll := MongoClient.Database(DatabaseName).Collection("pis_testing")
crsIndex := mongo.IndexModel{ crsIndex := mongo.IndexModel{
Keys: bson.D{{"stops", 1}}, Keys: bson.D{{"stops", 1}},

View File

@ -5,7 +5,7 @@ import (
) )
// Version Constants // Version Constants
const versionNum string = "2025.01.1" const versionNum string = "2024.11.4"
const versionSuffix string = "" const versionSuffix string = ""
const Version string = versionNum + versionSuffix const Version string = versionNum + versionSuffix

View File

@ -56,7 +56,7 @@ func Check() {
} }
if oldMetadata != nil { if oldMetadata != nil {
if oldMetadata.LastVersion == apiResp.Name { if oldMetadata.LastVersion != apiResp.Name {
log.Info("PIS Data is up to date") log.Info("PIS Data is up to date")
return return
} }
@ -67,9 +67,4 @@ func Check() {
if err != nil { if err != nil {
log.Error("Error updating PIS Data", zap.Error(err)) log.Error("Error updating PIS Data", zap.Error(err))
} }
err = dbAccess.PutPisMetadata(apiResp.Name)
if err != nil {
log.Error("Error updating PIS Metadata", zap.Error(err))
}
} }

View File

@ -54,7 +54,8 @@ func runUpdate(tarballUrl string) error {
} }
log.Info("Loaded PIS Files to Slice") log.Info("Loaded PIS Files to Slice")
err = dbAccess.DropCollection(dbAccess.PisCollection) // Temporarily use "pis_testing" collection to ensure all works as expected
err = dbAccess.DropCollection("pis_testing")
if err != nil { if err != nil {
return err return err
} }