diff options
| author | JP Dillingham <jp@dillingham.me> | 2024-10-06 16:56:27 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2024-10-06 16:56:27 -0500 |
| commit | 8d919e494ef53fbdf625540971414d26c06a96fb (patch) | |
| tree | 8806c87048477fc416c67a3065c3936ae305651d /src/slskd/Events/EventService.cs | |
| parent | c0e02f9806ed95dd43bbb7bff74d6abe5e66109c (diff) | |
| download | slskd-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.cs | 19 |
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> |
