Skip to content

Usenet streaming with a WebDAV server and a SABnzbd-compatible API

C#

Fixed bug counting number of unchecked items on health page (#136)

nzbdav-deve4dbb415a6db
diff --git a/backend/Api/Controllers/GetHealthCheckQueue/GetHealthCheckQueueController.cs b/backend/Api/Controllers/GetHealthCheckQueue/GetHealthCheckQueueController.cs
index f73dd1bf..a2c0aad9 100644
--- a/backend/Api/Controllers/GetHealthCheckQueue/GetHealthCheckQueueController.cs
+++ b/backend/Api/Controllers/GetHealthCheckQueue/GetHealthCheckQueueController.cs
@@ -16,10 +16,7 @@ public class GetHealthCheckQueueController(DavDatabaseClient dbClient) : BaseApi
.Take(request.PageSize)
.ToListAsync();
- var uncheckedCount = await dbClient.Ctx.Items
- .Where(x => x.Type == DavItem.ItemType.NzbFile
- || x.Type == DavItem.ItemType.RarFile
- || x.Type == DavItem.ItemType.MultipartFile)
+ var uncheckedCount = await HealthCheckService.GetHealthCheckQueueItemsQuery(dbClient)
.Where(x => x.NextHealthCheck == null)
.CountAsync();
diff --git a/backend/Services/HealthCheckService.cs b/backend/Services/HealthCheckService.cs
index b71b50ea..efc70fe1 100644
--- a/backend/Services/HealthCheckService.cs
+++ b/backend/Services/HealthCheckService.cs
@@ -91,6 +91,14 @@ public class HealthCheckService
}
public static IOrderedQueryable<DavItem> GetHealthCheckQueueItems(DavDatabaseClient dbClient)
+ {
+ return GetHealthCheckQueueItemsQuery(dbClient)
+ .OrderBy(x => x.NextHealthCheck)
+ .ThenByDescending(x => x.ReleaseDate)
+ .ThenBy(x => x.Id);
+ }
+
+ public static IQueryable<DavItem> GetHealthCheckQueueItemsQuery(DavDatabaseClient dbClient)
{
var actionNeeded = HealthCheckResult.RepairAction.ActionNeeded;
var healthCheckResults = dbClient.Ctx.HealthCheckResults;
@@ -98,10 +106,7 @@ public class HealthCheckService
.Where(x => x.Type == DavItem.ItemType.NzbFile
|| x.Type == DavItem.ItemType.RarFile
|| x.Type == DavItem.ItemType.MultipartFile)
- .Where(x => !healthCheckResults.Any(h => h.DavItemId == x.Id && h.RepairStatus == actionNeeded))
- .OrderBy(x => x.NextHealthCheck)
- .ThenByDescending(x => x.ReleaseDate)
- .ThenBy(x => x.Id);
+ .Where(x => !healthCheckResults.Any(h => h.DavItemId == x.Id && h.RepairStatus == actionNeeded));
}
private async Task PerformHealthCheck