From d226564eb02e7a0f681069b6bfccb94e2f7fbfb0 Mon Sep 17 00:00:00 2001 From: "Collin M. Barrett" Date: Mon, 27 Aug 2018 17:22:40 -0500 Subject: [PATCH] cleanup orphaned rules --- src/FilterLists.Services/Snapshot/SnapshotService.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/FilterLists.Services/Snapshot/SnapshotService.cs b/src/FilterLists.Services/Snapshot/SnapshotService.cs index dea8410c2..e7dc270a9 100644 --- a/src/FilterLists.Services/Snapshot/SnapshotService.cs +++ b/src/FilterLists.Services/Snapshot/SnapshotService.cs @@ -33,6 +33,7 @@ public async Task CaptureAsync(int batchSize) private async Task CleanupFailedSnapshots() { DbContext.RemoveRange(DbContext.SnapshotRules.Where(sr => !sr.Snapshot.WasSuccessful)); + DbContext.RemoveRange(DbContext.Rules.Where(r => !r.SnapshotRules.Any())); await DbContext.SaveChangesAsync(); }