Files
TeleWave/backend/src/TeleWave.Application/Programming/Groups/ListGroups/ListGroupsQueryHandler.cs
T
Leonid Pershin 91af589547
ci / build-backend (push) Successful in 2m30s
ci / build-frontend (push) Successful in 43s
ci / tests (push) Successful in 2m36s
ci / sonar (push) Failing after 33s
Implement dynamic group management features with exclusions and mode handling
Enhanced the group management system by introducing dynamic group capabilities, allowing for the exclusion of elements from dynamic groups. Updated the Group and GroupItem models to support a new GroupMode, enabling the distinction between static and dynamic groups. Implemented API endpoints for excluding elements and updated related services to handle group composition based on the selected mode. Improved the frontend to accommodate these changes, including new API functions and UI components for managing exclusions and group modes, thereby enhancing the overall user experience in group management.
2026-07-27 05:03:09 +03:00

37 lines
1.5 KiB
C#

using LiteCqrs;
using Microsoft.EntityFrameworkCore;
using TeleWave.Application.Common.Interfaces;
namespace TeleWave.Application.Programming.Groups.ListGroups;
public sealed class ListGroupsQueryHandler(IAppDbContext dbContext)
: IQueryHandler<ListGroupsQuery, IReadOnlyList<GroupSummaryDto>>
{
public async Task<IReadOnlyList<GroupSummaryDto>> Handle(
ListGroupsQuery query,
CancellationToken cancellationToken
)
{
// Список читает кэш статистики, не пересчитывая его: пересчёт идёт при правке состава и при
// открытии карточки. У динамической группы кэш поэтому может отставать от библиотеки —
// рядом с цифрами показывается время расчёта (StatsComputedAt), и это честнее, чем гонять
// правила всех групп на каждый показ списка.
return await dbContext
.Groups.AsNoTracking()
.OrderBy(g => g.Name)
.Select(g => new GroupSummaryDto(
g.Id,
g.Name,
g.Description,
g.ItemCount,
g.UnitCount,
g.TotalDuration.TotalSeconds,
g.FilterJson != null,
g.Mode,
g.StatsComputedAt,
g.CreatedAt
))
.ToListAsync(cancellationToken);
}
}