Refactor user and media endpoints: remove unused GetUser and GetMedia methods, streamline AdminUserEndpoints and MediaEndpoints, and enhance metadata handling in MetadataEndpoints. Update Program.cs to remove legacy image relocation logic and improve overall code clarity.
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
using LiteCqrs;
|
||||
using TeleWave.Application.Common.Models;
|
||||
|
||||
namespace TeleWave.Application.Media.GetMedia;
|
||||
|
||||
public sealed record GetMediaAssetQuery(Guid Id) : IQuery<Result<MediaAssetDto>>;
|
||||
@@ -1,24 +0,0 @@
|
||||
using LiteCqrs;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using TeleWave.Application.Common.Interfaces;
|
||||
using TeleWave.Application.Common.Models;
|
||||
|
||||
namespace TeleWave.Application.Media.GetMedia;
|
||||
|
||||
public sealed class GetMediaAssetQueryHandler(IAppDbContext dbContext)
|
||||
: IQueryHandler<GetMediaAssetQuery, Result<MediaAssetDto>>
|
||||
{
|
||||
public async Task<Result<MediaAssetDto>> Handle(
|
||||
GetMediaAssetQuery query,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var asset = await dbContext
|
||||
.MediaAssets.AsNoTracking()
|
||||
.FirstOrDefaultAsync(x => x.Id == query.Id, cancellationToken);
|
||||
|
||||
return asset is null
|
||||
? Result.Failure<MediaAssetDto>(MediaErrors.NotFound)
|
||||
: Result.Success(MediaAssetDto.From(asset));
|
||||
}
|
||||
}
|
||||
@@ -17,9 +17,14 @@ public sealed class GetMediaStatsQueryHandler(IAppDbContext dbContext)
|
||||
)
|
||||
{
|
||||
// Сгенерированные (ТВ-заставки) в статистику библиотеки не входят.
|
||||
var assets = dbContext.MediaAssets.AsNoTracking().Where(x => x.Source != MediaSource.Generated);
|
||||
var assets = dbContext
|
||||
.MediaAssets.AsNoTracking()
|
||||
.Where(x => x.Source != MediaSource.Generated);
|
||||
|
||||
var queued = await assets.CountAsync(x => x.Status == MediaAssetStatus.Pending, cancellationToken);
|
||||
var queued = await assets.CountAsync(
|
||||
x => x.Status == MediaAssetStatus.Pending,
|
||||
cancellationToken
|
||||
);
|
||||
var processing = await assets.CountAsync(
|
||||
x => x.Status == MediaAssetStatus.Processing,
|
||||
cancellationToken
|
||||
|
||||
Reference in New Issue
Block a user