Adds the music play statistics endpoints and moves the Web statistics page under the library

This commit is contained in:
BinaryAlley committed 2026-10-25 13:19:24 +02:00
1 parent dfd979ec1e
commit a61fbf407c
69 files changed
+3407 -7

No files matched your search

@@ -25,6 +25,11 @@ namespace Lumina.Domain.Core.BoundedContexts.MusicPlayHistoryBoundedContext.Musi
[DebuggerDisplay("Id: {Id.Value}; TrackId: {TrackId.Value}; Status: {Status}")]
public sealed class MusicPlayRecord : AggregateRoot<MusicPlayRecordId>
{
/// <summary>
/// The minimum number of seconds a user must listen to a track for the play to count, unless the play completed first.
/// </summary>
private const int MINIMUM_COUNTED_LISTENED_DURATION_SECONDS = 30;
/// <summary>
/// Gets the object representing the unique identifier of the user that started the play.
/// </summary>
@@ -208,6 +213,17 @@ public sealed class MusicPlayRecord : AggregateRoot<MusicPlayRecordId>
updatedOnUtc);
}
/// <summary>
/// Determines whether a play with the provided <paramref name="status"/> and <paramref name="listenedDuration"/> counts as a play for the listening statistics.
/// </summary>
/// <param name="status">The state of the recorded play.</param>
/// <param name="listenedDuration">The duration that the user has listened to.</param>
/// <returns><see langword="true"/> when the play counts, <see langword="false"/> otherwise.</returns>
public static bool DoesCountAsPlay(PlaybackRecordStatus status, TimeSpan listenedDuration)
{
return status == PlaybackRecordStatus.Completed || listenedDuration.TotalSeconds >= MINIMUM_COUNTED_LISTENED_DURATION_SECONDS;
}
/// <summary>
/// Updates the last reported position and the listened duration of an in-progress play.
/// </summary>