cleanup failed snapshots

This commit is contained in:
Collin M. Barrett 2018-08-24 18:28:35 -05:00
parent f7943e665f
commit 94cc20bf62

View file

@ -23,6 +23,7 @@ public SnapshotService(FilterListsDbContext dbContext, IConfigurationProvider ma
public async Task CaptureAsync(int batchSize)
{
await CleanupFailedSnapshots();
uaString = await UserAgentService.GetMostPopularString();
var lists = await GetListsToCapture(batchSize);
var snaps = await CreateAndSaveSnaps<Snapshot>(lists);
@ -30,6 +31,12 @@ public async Task CaptureAsync(int batchSize)
await CreateAndSaveSnaps<SnapshotWayback>(listsToRetry);
}
private async Task CleanupFailedSnapshots()
{
DbContext.SnapshotRules.RemoveRange(DbContext.SnapshotRules.Where(sr => !sr.Snapshot.WasSuccessful));
await DbContext.SaveChangesAsync();
}
private async Task<IEnumerable<FilterListViewUrlDto>> GetListsToCapture(int batchSize) =>
await DbContext
.FilterLists