Implement collection suggestions and bulk show addition features
Added new API endpoints for suggesting collections based on existing shows and for bulk adding shows to collections. Enhanced the backend with necessary logic and DTOs to support these features. Updated the frontend to include new components for displaying collection suggestions and managing bulk additions, improving the user experience for collection management. Localization updates were made to support these new features in both English and Russian.
This commit is contained in:
+40
@@ -0,0 +1,40 @@
|
||||
using LiteCqrs;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using TeleWave.Application.Common.Interfaces;
|
||||
|
||||
namespace TeleWave.Application.Library.Collections.Suggest;
|
||||
|
||||
public sealed class SuggestCollectionsQueryHandler(
|
||||
IAppDbContext dbContext,
|
||||
CollectionSuggestionBuilder builder
|
||||
) : IQueryHandler<SuggestCollectionsQuery, IReadOnlyList<CollectionSuggestionDto>>
|
||||
{
|
||||
public async Task<IReadOnlyList<CollectionSuggestionDto>> Handle(
|
||||
SuggestCollectionsQuery query,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var suggestions = await builder.BuildAsync(cancellationToken);
|
||||
if (suggestions.Count == 0)
|
||||
return [];
|
||||
|
||||
var names = await dbContext
|
||||
.Collections.AsNoTracking()
|
||||
.Select(c => c.Name)
|
||||
.ToListAsync(cancellationToken);
|
||||
var existing = names
|
||||
.Select(n => n.Trim())
|
||||
.ToHashSet(StringComparer.CurrentCultureIgnoreCase);
|
||||
|
||||
return
|
||||
[
|
||||
.. suggestions.Select(s => new CollectionSuggestionDto(
|
||||
s.Key,
|
||||
s.Source,
|
||||
s.Name,
|
||||
s.Parts,
|
||||
existing.Contains(s.Name)
|
||||
)),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user