mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 13:11:10 +00:00
Adds the music play statistics endpoints and moves the Web statistics page under the library
This commit is contained in:
1 parent
dfd979ec1e
commit
a61fbf407c
69 files changed
+3407
-7
No files matched your search
+16
@@ -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>
|
||||
|
||||
Reference in new issue
Block a user