timetable-extension #1

Open
fred.boniface wants to merge 160 commits from timetable-extension into main
Showing only changes of commit fe059abd6c - Show all commits

View File

@ -152,7 +152,7 @@ func RemoveOutdatedServices(cutoff time.Time) (count int64, err error) {
return // Automatically returns names values return // Automatically returns names values
} }
// Creates indexes on the Timetable collection // Creates indexes on the Timetable collection... Index suitability needs checking.
func CreateTimetableIndexes() error { func CreateTimetableIndexes() error {
coll := MongoClient.Database(DatabaseName).Collection(TimetableCollection) coll := MongoClient.Database(DatabaseName).Collection(TimetableCollection)
indexModels := []mongo.IndexModel{ indexModels := []mongo.IndexModel{
@ -164,6 +164,24 @@ func CreateTimetableIndexes() error {
}, },
Options: options.Index().SetName("delete_query"), Options: options.Index().SetName("delete_query"),
}, },
{
Keys: bson.M{
"trainUid": 1,
"scheduleStartDate": 1,
"scheduleEndDate": 1,
"daysRun": 1,
},
Options: options.Index().SetName("find_by_uid"),
},
{
Keys: bson.M{
"headcode": 1,
"scheduleStartDate": 1,
"scheduleEndDate": 1,
"daysRun": 1,
},
Options: options.Index().SetName("find_by_headcode"),
},
} }
_, err := coll.Indexes().CreateMany(context.Background(), indexModels) _, err := coll.Indexes().CreateMany(context.Background(), indexModels)