timetable-extension #1

Open
fred.boniface wants to merge 144 commits from timetable-extension into main
1 changed files with 19 additions and 1 deletions
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
}
// Creates indexes on the Timetable collection
// Creates indexes on the Timetable collection... Index suitability needs checking.
func CreateTimetableIndexes() error {
coll := MongoClient.Database(DatabaseName).Collection(TimetableCollection)
indexModels := []mongo.IndexModel{
@ -164,6 +164,24 @@ func CreateTimetableIndexes() error {
},
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)