Adds media consumption contracts, DTOs, and mappings

This commit is contained in:
BinaryAlley committed 2026-10-24 14:09:36 +03:00
1 parent 9247d9fe0f
commit 822ccc9adc
34 files changed
+1374

No files matched your search

@@ -0,0 +1,38 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Responses.MediaConsumption;
/// <summary>
/// Represents a media item of the consumption history, together with its aggregated consumption counts and display details.
/// </summary>
/// <param name="MediaKind">The kind of the consumed media item.</param>
/// <param name="MediaItemId">The Id of the consumed media item.</param>
/// <param name="LibraryId">The Id of the media library that contains the media item.</param>
/// <param name="IsAvailable">Whether the media item still exists and can be accessed by the user. When <see langword="false"/>, the title, collection title, creator name, and cover path are blank, while the identity and aggregation fields remain.</param>
/// <param name="Title">The title of the media item, or an empty string when the item is not available.</param>
/// <param name="CollectionTitle">The title of the collection that contains the media item, or an empty string when there is none.</param>
/// <param name="CreatorName">The name of the creator of the media item, or an empty string when there is none.</param>
/// <param name="CoverPath">The path of the cover art of the media item, if available.</param>
/// <param name="LastConsumedOnUtc">The date and time when the media item was last consumed.</param>
/// <param name="CountedSessionCount">The number of consumption sessions of the media item that count towards statistics.</param>
/// <param name="CompletedSessionCount">The number of consumption sessions of the media item that completed.</param>
/// <param name="ConsumedDurationInSeconds">The active duration consumed in the media item, over all of its sessions, in seconds.</param>
[DebuggerDisplay("MediaKind: {MediaKind}; MediaItemId: {MediaItemId}; CountedSessionCount: {CountedSessionCount}")]
public sealed record ConsumedItemResponse(
MediaKind MediaKind,
Guid MediaItemId,
Guid LibraryId,
bool IsAvailable,
string Title,
string CollectionTitle,
string CreatorName,
string? CoverPath,
DateTime LastConsumedOnUtc,
int CountedSessionCount,
int CompletedSessionCount,
double ConsumedDurationInSeconds
);
@@ -0,0 +1,39 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Responses.MediaConsumption;
/// <summary>
/// Represents a media consumption session.
/// </summary>
/// <param name="Id">The Id of the consumption record.</param>
/// <param name="LibraryId">The Id of the media library that contains the consumed media item.</param>
/// <param name="MediaItemId">The Id of the consumed media item.</param>
/// <param name="MediaKind">The kind of media that was consumed.</param>
/// <param name="Status">The state of the consumption session.</param>
/// <param name="StartedOnUtc">The date and time when the session started.</param>
/// <param name="LastActivityOnUtc">The date and time when the session last received activity.</param>
/// <param name="EndedOnUtc">The date and time when the session completed or stopped, if it has ended.</param>
/// <param name="ConsumedDurationInSeconds">The active duration consumed by the session, in seconds.</param>
/// <param name="LastPosition">The last known position for the media item, if any.</param>
/// <param name="LastProgressFraction">The latest reported progress fraction of the media item.</param>
/// <param name="ConsecutivePagesRead">The number of consecutive pages read in the session.</param>
[DebuggerDisplay("Id: {Id}; MediaKind: {MediaKind}; Status: {Status}")]
public sealed record ConsumptionRecordResponse(
Guid Id,
Guid LibraryId,
Guid MediaItemId,
MediaKind MediaKind,
ConsumptionStatus Status,
DateTime StartedOnUtc,
DateTime LastActivityOnUtc,
DateTime? EndedOnUtc,
double ConsumedDurationInSeconds,
MediaPositionResponse? LastPosition,
double LastProgressFraction,
int ConsecutivePagesRead
);
@@ -0,0 +1,28 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Responses.MediaConsumption;
/// <summary>
/// Represents the consumption statistics of a user.
/// </summary>
/// <param name="UserId">The Id of the user the statistics belong to.</param>
/// <param name="TotalConsumedDurationInSeconds">The total duration consumed over every recorded session, in seconds.</param>
/// <param name="CountedSessionCount">The number of recorded sessions that count towards statistics.</param>
/// <param name="CompletedSessionCount">The number of recorded sessions that completed.</param>
/// <param name="StoppedSessionCount">The number of recorded sessions that stopped before they completed and count towards statistics.</param>
/// <param name="CompletionRate">The fraction of the counted sessions that completed, between 0 and 1, or 0 when there is no counted session.</param>
/// <param name="MediaKindSummaries">The consumption statistics broken down by media kind.</param>
[DebuggerDisplay("UserId: {UserId}; CountedSessionCount: {CountedSessionCount}")]
public sealed record ConsumptionSummaryResponse(
Guid UserId,
double TotalConsumedDurationInSeconds,
int CountedSessionCount,
int CompletedSessionCount,
int StoppedSessionCount,
double CompletionRate,
IReadOnlyList<MediaKindConsumptionSummaryResponse> MediaKindSummaries
);
@@ -0,0 +1,25 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Responses.MediaConsumption;
/// <summary>
/// Represents the consumption statistics of a user for one kind of media.
/// </summary>
/// <param name="MediaKind">The kind of media the statistics belong to.</param>
/// <param name="TotalConsumedDurationInSeconds">The total duration consumed over every recorded session of the media kind, in seconds.</param>
/// <param name="CountedSessionCount">The number of recorded sessions of the media kind that count towards statistics.</param>
/// <param name="CompletedSessionCount">The number of recorded sessions of the media kind that completed.</param>
/// <param name="StoppedSessionCount">The number of recorded sessions of the media kind that stopped before they completed and count towards statistics.</param>
/// <param name="CompletionRate">The fraction of the counted sessions of the media kind that completed, between 0 and 1, or 0 when there is no counted session.</param>
[DebuggerDisplay("MediaKind: {MediaKind}; CountedSessionCount: {CountedSessionCount}")]
public sealed record MediaKindConsumptionSummaryResponse(
MediaKind MediaKind,
double TotalConsumedDurationInSeconds,
int CountedSessionCount,
int CompletedSessionCount,
int StoppedSessionCount,
double CompletionRate
);
@@ -0,0 +1,19 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Responses.MediaConsumption;
/// <summary>
/// Represents a position reached in a media item during a consumption session.
/// </summary>
/// <param name="Kind">The kind of representation used by the position.</param>
/// <param name="TimeOffsetSeconds">The position within the media item, in seconds, when the position is a time offset.</param>
/// <param name="Location">The opaque locator within the media item, when the position is not a time offset.</param>
[DebuggerDisplay("Kind: {Kind}; TimeOffsetSeconds: {TimeOffsetSeconds}")]
public sealed record MediaPositionResponse(
MediaPositionKind Kind,
double? TimeOffsetSeconds,
string? Location
);
@@ -0,0 +1,28 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Responses.MediaConsumption;
/// <summary>
/// Represents the point at which a user can resume consuming a media item.
/// </summary>
/// <param name="Id">The Id of the resume point.</param>
/// <param name="LibraryId">The Id of the media library that contains the media item.</param>
/// <param name="MediaItemId">The Id of the media item to resume.</param>
/// <param name="MediaKind">The kind of media that is resumed.</param>
/// <param name="LastPosition">The position at which the media item can be resumed.</param>
/// <param name="LastProgressFraction">The progress fraction at which the media item can be resumed.</param>
/// <param name="LastConsumedOnUtc">The date and time when the media item was last consumed.</param>
[DebuggerDisplay("Id: {Id}; MediaKind: {MediaKind}; MediaItemId: {MediaItemId}")]
public sealed record ResumePointResponse(
Guid Id,
Guid LibraryId,
Guid MediaItemId,
MediaKind MediaKind,
MediaPositionResponse LastPosition,
double LastProgressFraction,
DateTime LastConsumedOnUtc
);
@@ -0,0 +1,21 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.SharedKernel.Common.Enums.MediaConsumption;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Responses.MediaConsumption;
/// <summary>
/// Represents the consumption statistics of a tag or genre, grouped across media kinds.
/// </summary>
/// <param name="Name">The lowercase name of the tag or genre.</param>
/// <param name="TagKind">Whether the entry is a genre or a tag.</param>
/// <param name="ConsumedItemCount">The number of distinct media items that carry the term and were consumed.</param>
/// <param name="ConsumedDurationInSeconds">The active duration consumed in the media items that carry the term, in seconds.</param>
[DebuggerDisplay("TagKind: {TagKind}; Name: {Name}; ConsumedItemCount: {ConsumedItemCount}")]
public sealed record TagConsumptionResponse(
string Name,
TagKind TagKind,
int ConsumedItemCount,
double ConsumedDurationInSeconds
);