aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Events/EventService.cs
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2024-10-06 16:56:27 -0500
committerJP Dillingham <jp@dillingham.me>2024-10-06 16:56:27 -0500
commit8d919e494ef53fbdf625540971414d26c06a96fb (patch)
tree8806c87048477fc416c67a3065c3936ae305651d /src/slskd/Events/EventService.cs
parentc0e02f9806ed95dd43bbb7bff74d6abe5e66109c (diff)
downloadslskd-8d919e494ef53fbdf625540971414d26c06a96fb.tar.gz
add X-Total-Count to events GET
Diffstat (limited to 'src/slskd/Events/EventService.cs')
-rw-r--r--src/slskd/Events/EventService.cs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/slskd/Events/EventService.cs b/src/slskd/Events/EventService.cs
index 0406f83d..72a71d22 100644
--- a/src/slskd/Events/EventService.cs
+++ b/src/slskd/Events/EventService.cs
@@ -74,6 +74,25 @@ public class EventService
}
/// <summary>
+ /// Gets the total number of events.
+ /// </summary>
+ /// <returns>The total number of events.</returns>
+ public virtual int Count()
+ {
+ try
+ {
+ using var context = ContextFactory.CreateDbContext();
+ var count = context.Events.Count();
+ return count;
+ }
+ catch (Exception ex)
+ {
+ Log.Error(ex, "Failed to count event records: {Message}", ex.Message);
+ throw;
+ }
+ }
+
+ /// <summary>
/// Adds the specified event <paramref name="eventRecord"/>.
/// </summary>
/// <remarks>