using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.DTO.Report; using GB5Shared.FastEndPoint; using RecruitmentBLL.Reports.PipelineConversionFunnel; using RecruitmentDAL.DTO.Reports; using static GB5Shared.GB5Constant.Constant; namespace RecruitmentSL.EndPoints.RecruitmentReports { // Phase 5 analytics — pipeline-conversion (funnel) report. Row grain: one row per // SelectionProcessStage ordered by StageOrder within its template — see // PipelineConversionFunnelDTO's doc comment. ReportCallingDTO.CriteriaDTO.Id, when > 0, scopes // the funnel to a single SelectionProcessTemplateId; omitted/0 returns every template's funnel // for the tenant. public class GetPipelineConversionFunnel : BaseReportEndpoint { private readonly IPipelineConversionFunnelBLL _bll; public GetPipelineConversionFunnel(IPipelineConversionFunnelBLL bll) { _bll = bll; } public override void Configure() { Post("/RecruitmentReports/GetPipelineConversionFunnel"); AllowAnonymous(); } public record GetPipelineConversionFunnelParameter( [property: FromHeader] string Login, [property: FromBody] ReportCallingDTO ReportCallingDTO, [property: QueryParam] int FirstNumber, [property: QueryParam] int MaxResult, [property: QueryParam] int MenuId ); protected override IAsyncEnumerable ExecuteReportAsync( GetPipelineConversionFunnelParameter req, LoginDTO login, CancellationToken ct) => _bll.GetPipelineConversionFunnelStream( req.FirstNumber, req.MaxResult, req.ReportCallingDTO?.CriteriaDTO, login, ct); protected override async Task> ExecutePagedAsync( GetPipelineConversionFunnelParameter req, LoginDTO login, CancellationToken ct) { var result = await _bll.GetPipelineConversionFunnel( req.FirstNumber, req.MaxResult, req.ReportCallingDTO?.CriteriaDTO, login, ct).ConfigureAwait(false); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.NOT_REQUIRED, login); } } }