From 72a1368b7ff65dbb504a31fb2b9dcfc51d8a88b3 Mon Sep 17 00:00:00 2001 From: Collin Barrett Date: Sat, 10 Feb 2018 18:50:13 -0600 Subject: [PATCH] try capture snapshots every minute with max of once per list per day --- cron.txt | 4 ++-- src/FilterLists.Agent/Program.cs | 1 - .../SnapshotService/SnapshotService.cs | 7 ++++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cron.txt b/cron.txt index 9833784c7..5a6a63b85 100644 --- a/cron.txt +++ b/cron.txt @@ -1,2 +1,2 @@ -# FilterLists - Capture Snapshots Hourly (skips if previous still running) -0 * * * * /usr/bin/flock -n /tmp/filterlistsagent.lockfile /var/www/filterlists/FilterLists.Agent > /dev/null 2>&1 \ No newline at end of file +# FilterLists - Try Capture Snapshots Every Minute (skips if previous still running) +*/1 * * * * /usr/bin/flock -n /tmp/filterlistsagent.lockfile /var/www/filterlists/FilterLists.Agent > /dev/null 2>&1 \ No newline at end of file diff --git a/src/FilterLists.Agent/Program.cs b/src/FilterLists.Agent/Program.cs index cb346366f..25fa6c975 100644 --- a/src/FilterLists.Agent/Program.cs +++ b/src/FilterLists.Agent/Program.cs @@ -21,7 +21,6 @@ public static int Main(string[] args) InstantiateTelemetryClient(); InstantiateServiceProvider(); - //TODO: capture batchSize from args const int batchSize = 1; CaptureSnapshots(batchSize); diff --git a/src/FilterLists.Services/SnapshotService/SnapshotService.cs b/src/FilterLists.Services/SnapshotService/SnapshotService.cs index 174b88707..5a4d9815b 100644 --- a/src/FilterLists.Services/SnapshotService/SnapshotService.cs +++ b/src/FilterLists.Services/SnapshotService/SnapshotService.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using AutoMapper.QueryableExtensions; @@ -39,6 +40,10 @@ private async Task> GetLeastRecentlyCapturedLi .Select(y => y.CreatedDateUtc) .OrderByDescending(y => y) .FirstOrDefault()) + .Where(x => x.Snapshots + .Select(y => y.CreatedDateUtc) + .OrderByDescending(y => y) + .FirstOrDefault() < DateTime.UtcNow.AddDays(-1)) .Take(batchSize) .AsNoTracking() .ProjectTo()