simplify CaptureAsync()

This commit is contained in:
Collin Barrett 2018-08-25 09:07:53 -05:00
parent 5d6851011b
commit f48b3410d4

View file

@ -14,7 +14,6 @@ namespace FilterLists.Services.Snapshot
public class SnapshotService : Service
{
private readonly BatchSizeService batchSizeService;
private readonly DateTime yesterday = DateTime.UtcNow.AddDays(-1);
private string uaString;
public SnapshotService(FilterListsDbContext dbContext, IConfigurationProvider mapConfig,
@ -35,17 +34,8 @@ await DbContext
.FilterLists
.Where(l => !l.CantSnapshot &&
!(l.ViewUrl.StartsWith(WaybackService.WaybackMachineUrlPrefix) &&
l.Snapshots.Any(s => s.WasSuccessful)) &&
(!l.Snapshots.Any() ||
l.Snapshots
.Select(s => s.CreatedDateUtc)
.OrderByDescending(d => d)
.First() < yesterday))
l.Snapshots.Any(s => s.WasSuccessful)))
.OrderBy(l => l.Snapshots.Any())
.ThenBy(l => l.Snapshots
.OrderByDescending(s => s.CreatedDateUtc)
.FirstOrDefault()
.WasSuccessful)
.ThenBy(l => l.Snapshots
.Select(s => s.CreatedDateUtc)
.OrderByDescending(d => d)