Skip to content

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

C#

Added total number of items to GetHistory api response.

nzbdav-deve33507de7ccf
diff --git a/backend/Api/SabControllers/GetHistory/GetHistoryController.cs b/backend/Api/SabControllers/GetHistory/GetHistoryController.cs
index d4f1a20c..ca5d70b8 100644
--- a/backend/Api/SabControllers/GetHistory/GetHistoryController.cs
+++ b/backend/Api/SabControllers/GetHistory/GetHistoryController.cs
@@ -1,4 +1,4 @@
-using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using NzbWebDAV.Config;
@@ -14,6 +14,11 @@ public class GetHistoryController(
{
private async Task<GetHistoryResponse> GetHistoryAsync(GetHistoryRequest request)
{
+ // get total count
+ var totalCount = await dbClient.Ctx.HistoryItems
+ .Where(q => q.Category == request.Category || request.Category == null)
+ .CountAsync(request.CancellationToken);
+
// get history items
var historyItems = await dbClient.Ctx.HistoryItems
.Where(q => q.Category == request.Category || request.Category == null)
@@ -33,6 +38,7 @@ public class GetHistoryController(
History = new GetHistoryResponse.HistoryObject()
{
Slots = slots,
+ TotalCount = totalCount,
}
};
}
diff --git a/backend/Api/SabControllers/GetHistory/GetHistoryResponse.cs b/backend/Api/SabControllers/GetHistory/GetHistoryResponse.cs
index f0f9e9b8..98a67f92 100644
--- a/backend/Api/SabControllers/GetHistory/GetHistoryResponse.cs
+++ b/backend/Api/SabControllers/GetHistory/GetHistoryResponse.cs
@@ -1,4 +1,4 @@
-using System.Text.Json.Serialization;
+using System.Text.Json.Serialization;
using NzbWebDAV.Database.Models;
namespace NzbWebDAV.Api.SabControllers.GetHistory;
@@ -12,6 +12,9 @@ public class GetHistoryResponse : SabBaseResponse
{
[JsonPropertyName("slots")]
public List<HistorySlot> Slots { get; set; }
+
+ [JsonPropertyName("noofslots")]
+ public int TotalCount { get; set; }
}
public class HistorySlot