mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 12:11:10 +00:00
Adds real time media libraries scan progress update via SignalR
This commit is contained in:
1 parent
d70b2dcaa0
commit
e0d61802df
71 files changed
+1292
-131
No files matched your search
+7
-1
@@ -32,6 +32,9 @@ public class GetLibraryScanProgressEndpointSummary : Summary<GetLibraryScanProgr
|
||||
RequestParam(r => r.LibraryId, "The Id of the media library whose scan progress is requested. Required.");
|
||||
RequestParam(r => r.ScanId, "The Id of the media library scan whose progress is requested. Required.");
|
||||
|
||||
ResponseParam<MediaLibraryScanProgressResponse>(r => r.ScanId, "The object representing the unique identifier of the media library scan.");
|
||||
ResponseParam<MediaLibraryScanProgressResponse>(r => r.UserId, "The object representing the unique identifier of the user initiating this media library scan.");
|
||||
ResponseParam<MediaLibraryScanProgressResponse>(r => r.LibraryId, "The object representing the unique identifier of the media library that is scanned.");
|
||||
ResponseParam<MediaLibraryScanProgressResponse>(r => r.TotalJobs, "The total number of jobs to be processed by the scan.");
|
||||
ResponseParam<MediaLibraryScanProgressResponse>(r => r.CompletedJobs, "The number of jobs that have been processed.");
|
||||
ResponseParam<MediaLibraryScanProgressResponse>(r => r.CurrentJobProgress, "The progress of the currently processing job.");
|
||||
@@ -39,6 +42,9 @@ public class GetLibraryScanProgressEndpointSummary : Summary<GetLibraryScanProgr
|
||||
ResponseParam<MediaLibraryScanProgressResponse>(r => r.OverallProgressPercentage, "The ratio between the number of processed jobs and the total number of jobs to process, as percentage.");
|
||||
|
||||
Response(200, "The progress of the media library scan is returned.", example: new MediaLibraryScanProgressResponse(
|
||||
ScanId: Guid.NewGuid(),
|
||||
UserId: Guid.NewGuid(),
|
||||
LibraryId: Guid.NewGuid(),
|
||||
TotalJobs: 10,
|
||||
CompletedJobs: 4,
|
||||
CurrentJobProgress: new MediaLibraryScanJobProgressResponse(
|
||||
@@ -47,7 +53,7 @@ public class GetLibraryScanProgressEndpointSummary : Summary<GetLibraryScanProgr
|
||||
CurrentOperation: "Comparing file hashes",
|
||||
ProgressPercentage: 50
|
||||
),
|
||||
Status: LibraryScanJobStatus.Running,
|
||||
Status: LibraryScanJobStatus.Running.ToString(),
|
||||
OverallProgressPercentage: 40
|
||||
));
|
||||
|
||||
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using ErrorOr;
|
||||
using FastEndpoints;
|
||||
using Lumina.Application.Core.MediaLibrary.Management.Queries.GetRunningLibraryScans;
|
||||
using Lumina.Contracts.Responses.MediaLibrary.Management;
|
||||
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
|
||||
using Lumina.Presentation.Api.Common.Routes.Library.Management;
|
||||
using Lumina.Presentation.Api.Core.Endpoints.Common;
|
||||
using Mediator;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Api.Core.Endpoints.Library.Management.GetRunningLibraryScans;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/libraries/scans/running</c> route.
|
||||
/// </summary>
|
||||
public class GetRunningLibraryScansEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
{
|
||||
private readonly ISender _sender;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetRunningLibraryScansEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="sender">Injected service for mediating commands and queries.</param>
|
||||
public GetRunningLibraryScansEndpoint(ISender sender)
|
||||
{
|
||||
_sender = sender;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the API endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
Verbs(Http.GET);
|
||||
Routes(ApiRoutes.Libraries.GET_RUNNING_LIBRARIES_SCAN);
|
||||
Version(1);
|
||||
DontCatchExceptions();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of ongoing media libraries scans.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(EmptyRequest _, CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorOr<IEnumerable<MediaLibraryScanProgressResponse>> result = await _sender.Send(new GetRunningLibraryScansQuery(), cancellationToken).ConfigureAwait(false);
|
||||
return result.Match(success => TypedResults.Ok(success), Problem);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user