timetable-extension #1

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

View File

@ -154,6 +154,7 @@ func RemoveOutdatedServices(cutoff time.Time) (count int64, err error) {
// Creates indexes on the Timetable collection... Index suitability needs checking. // Creates indexes on the Timetable collection... Index suitability needs checking.
func CreateTimetableIndexes() error { func CreateTimetableIndexes() error {
log.Info("Creating timetable indexes")
coll := MongoClient.Database(DatabaseName).Collection(TimetableCollection) coll := MongoClient.Database(DatabaseName).Collection(TimetableCollection)
indexModels := []mongo.IndexModel{ indexModels := []mongo.IndexModel{
{ {
@ -163,22 +164,13 @@ func CreateTimetableIndexes() error {
{Key: "scheduleStartDate", Value: 1}, {Key: "scheduleStartDate", Value: 1},
}, },
Options: options.Index().SetName("delete_query"), Options: options.Index().SetName("delete_query"),
}, }, // The find by UID Query can make use of the delete_query index
{
Keys: bson.D{
{Key: "trainUid", Value: 1},
{Key: "scheduleStartDate", Value: 1},
{Key: "scheduleEndDate", Value: 1},
{Key: "daysRun", Value: 1},
},
Options: options.Index().SetName("find_by_uid"),
},
{ {
Keys: bson.D{ Keys: bson.D{
{Key: "headcode", Value: 1}, {Key: "headcode", Value: 1},
{Key: "daysRun", Value: 1},
{Key: "scheduleStartDate", Value: 1}, {Key: "scheduleStartDate", Value: 1},
{Key: "scheduleEndDate", Value: 1}, {Key: "scheduleEndDate", Value: 1},
{Key: "daysRun", Value: 1},
}, },
Options: options.Index().SetName("find_by_headcode"), Options: options.Index().SetName("find_by_headcode"),
}, },