Prevent deleting VSTP services when completing full download.

This commit is contained in:
Fred Boniface
2024-04-23 20:49:28 +01:00
parent a2c5bd49ff
commit 9bd6bbde25
2 changed files with 21 additions and 2 deletions

View File

@@ -108,6 +108,19 @@ func DeleteCifEntries(deletions []database.DeleteQuery) error {
return nil
}
// Clears all non-vstp services from the database. Used when a CIF full download is required.
func PurgeNonVstp() (int64, error) {
coll := MongoClient.Database(DatabaseName).Collection(TimetableCollection)
filter := bson.M{"serviceDetail.vstp": false}
result, err := coll.DeleteMany(context.Background(), filter)
if err != nil {
return result.DeletedCount, err
}
return result.DeletedCount, nil
}
// Handles 'Create' tasks for CIF Schedule updates, accepts Service structs and batches their creation.
func CreateCifEntries(schedules []database.Service) error {
// Skip if deletions is empty