aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/slskd/Application.cs12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs
index 9016bd34..f7427612 100644
--- a/src/slskd/Application.cs
+++ b/src/slskd/Application.cs
@@ -567,11 +567,12 @@ namespace slskd
}
// start with weekly, as this is the most likely limit to be hit and we want to keep the work to a minimum
- var erroredState = (TransferStates.Completed | TransferStates.Errored).ToString();
+ var erroredState = TransferStates.Completed | TransferStates.Errored;
+ var cutoffDateTime = DateTime.UtcNow.AddDays(-7);
var weekly = Transfers.Uploads.Summarize(t =>
t.Username == username
- && t.StartedAt >= DateTime.UtcNow.AddDays(-7)
- && t.State.ToString() != erroredState
+ && t.StartedAt >= cutoffDateTime
+ && !t.State.HasFlag(erroredState)
&& t.Exception == null);
Log.Debug("Fetched weekly stats: {Stats} ({Time}ms)", weekly, sw.ElapsedMilliseconds);
@@ -582,10 +583,11 @@ namespace slskd
throw new DownloadEnqueueException($"Weekly {weeklyReason}");
}
+ cutoffDateTime = DateTime.UtcNow.AddDays(-1);
var daily = Transfers.Uploads.Summarize(t =>
t.Username == username
- && t.StartedAt >= DateTime.UtcNow.AddDays(-1)
- && t.State.ToString() != erroredState
+ && t.StartedAt >= cutoffDateTime
+ && !t.State.HasFlag(erroredState)
&& t.Exception == null);
Log.Debug("Fetched daily stats: {Stats} ({Time}ms)", weekly, sw.ElapsedMilliseconds);