Compare commits

...

6 Commits

Author SHA1 Message Date
e1c216f28f timetable-extension (#1)
All checks were successful
Go Test / test (push) Successful in 46s
Reviewed-on: #1
2025-06-18 21:06:02 +01:00
c9a6ef8006 Bump version
All checks were successful
Go Test / test (push) Successful in 34s
2025-01-18 00:28:22 +00:00
c6328acb1c Fix bug causing outdated PIS data to be marked as valid 2025-01-18 00:28:07 +00:00
f85a3da50e Fix TIPLOC/STANOX fetching code, fix logging for PIS metadata
All checks were successful
Go Test / test (push) Successful in 35s
2024-11-22 21:49:32 +00:00
2ef228a192 Enable writing of PIS Metadata
All checks were successful
Go Test / test (push) Successful in 35s
2024-11-22 21:38:53 +00:00
977ff77d50 Update PIS to use live db collection
All checks were successful
Go Test / test (push) Successful in 2m8s
2024-11-22 20:53:21 +00:00
6 changed files with 14 additions and 10 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -56,7 +56,7 @@ func Check() {
}
if oldMetadata != nil {
if oldMetadata.LastVersion != apiResp.Name {
if oldMetadata.LastVersion == apiResp.Name {
log.Info("PIS Data is up to date")
return
}
@ -67,4 +67,9 @@ func Check() {
if err != nil {
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,8 +54,7 @@ func runUpdate(tarballUrl string) error {
}
log.Info("Loaded PIS Files to Slice")
// Temporarily use "pis_testing" collection to ensure all works as expected
err = dbAccess.DropCollection("pis_testing")
err = dbAccess.DropCollection(dbAccess.PisCollection)
if err != nil {
return err
}