From 08f06beb2b41289d2e94914a28afda49b77753a0 Mon Sep 17 00:00:00 2001 From: Jared Goodwin Date: Wed, 31 Jul 2019 19:12:44 -0700 Subject: [PATCH] Modified data cleanup queries so they don't run locally. --- Server/CurrentVersion.txt | 2 +- Server/Data/DataService.cs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Server/CurrentVersion.txt b/Server/CurrentVersion.txt index 35dc0fcf..869a043c 100644 --- a/Server/CurrentVersion.txt +++ b/Server/CurrentVersion.txt @@ -1 +1 @@ -2019.07.23.1531 +2019.07.27.1108 diff --git a/Server/Data/DataService.cs b/Server/Data/DataService.cs index e1f44eff..c0d23ce2 100644 --- a/Server/Data/DataService.cs +++ b/Server/Data/DataService.cs @@ -497,18 +497,20 @@ namespace Remotely.Server.Data { if (AppConfig.DataRetentionInDays > 0) { + var expirationDate = DateTime.Now - TimeSpan.FromDays(AppConfig.DataRetentionInDays); + var eventLogs = RemotelyContext.EventLogs - .Where(x => DateTime.Now - x.TimeStamp > TimeSpan.FromDays(AppConfig.DataRetentionInDays)); + .Where(x => x.TimeStamp < expirationDate); RemotelyContext.RemoveRange(eventLogs); var commandContexts = RemotelyContext.CommandContexts - .Where(x => DateTime.Now - x.TimeStamp > TimeSpan.FromDays(AppConfig.DataRetentionInDays)); + .Where(x => x.TimeStamp < expirationDate); RemotelyContext.RemoveRange(commandContexts); var sharedFiles = RemotelyContext.SharedFiles - .Where(x => DateTime.Now - x.Timestamp > TimeSpan.FromDays(AppConfig.DataRetentionInDays)); + .Where(x => x.Timestamp < expirationDate); RemotelyContext.RemoveRange(sharedFiles);