From 2ca04fc68fbc921f005a23ba69b8a20b7fd254c0 Mon Sep 17 00:00:00 2001 From: Collin Barrett Date: Sat, 10 Feb 2018 19:05:23 -0600 Subject: [PATCH] fix bug in GetLeastRecentlyCapturedLists() --- .../SnapshotService/SnapshotService.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/FilterLists.Services/SnapshotService/SnapshotService.cs b/src/FilterLists.Services/SnapshotService/SnapshotService.cs index 5a4d9815b..0ceb038ac 100644 --- a/src/FilterLists.Services/SnapshotService/SnapshotService.cs +++ b/src/FilterLists.Services/SnapshotService/SnapshotService.cs @@ -34,16 +34,16 @@ private void RollbackIncomplete() private async Task> GetLeastRecentlyCapturedLists(int batchSize) { - return await dbContext.FilterLists - .OrderBy(x => x.Snapshots.Any()) - .ThenBy(x => x.Snapshots - .Select(y => y.CreatedDateUtc) - .OrderByDescending(y => y) - .FirstOrDefault()) - .Where(x => x.Snapshots - .Select(y => y.CreatedDateUtc) + return await dbContext.FilterLists.OrderBy(x => x.Snapshots.Any()) + .ThenBy(x => + x.Snapshots.Select(y => y.CreatedDateUtc) + .OrderByDescending(y => y) + .FirstOrDefault()) + .Where(x => !x.Snapshots.Any() || + x.Snapshots.Select(y => y.CreatedDateUtc) .OrderByDescending(y => y) - .FirstOrDefault() < DateTime.UtcNow.AddDays(-1)) + .FirstOrDefault() < + DateTime.UtcNow.AddDays(-1)) .Take(batchSize) .AsNoTracking() .ProjectTo()