using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.DTO.Report; using GB5Shared.FastEndPoint; using GB5Shared.QueryExecutor; using RecruitmentBLL.Reports.DeiSourcingReport; using RecruitmentDAL.DTO.Reports; using static GB5Shared.GB5Constant.Constant; namespace RecruitmentSL.EndPoints.RecruitmentReports { // Phase 5 analytics — aggregated-only DEI/diversity self-disclosure sourcing report. // Every row this endpoint can ever return has already passed DeiSourcingReportBLL's // mandatory cell-suppression rule (see that class's doc comment) — there is deliberately no // endpoint anywhere in this module that returns an individual MCANDIDATEDEMOGRAPHIC row. // // Follows the standard BaseReportEndpoint shape (CLAUDE.md "Report Endpoint // Template"): ExecuteReportAsync streams every (already-suppressed) row for exports/NDJSON; // ExecutePagedAsync is overridden because the DAL/BLL already do real grouping+suppression, so // the base class's weak 500-row default paging is bypassed in favor of the BLL's own paged // result (mirrors GetDayBooks's own override rationale in CLAUDE.md). public class GetDeiSourcingReport : BaseReportEndpoint { private readonly IDeiSourcingReportBLL _bll; public GetDeiSourcingReport(IDeiSourcingReportBLL bll) => _bll = bll; public override void Configure() { Post("/RecruitmentReports/GetDeiSourcingReport"); AllowAnonymous(); } public record GetDeiSourcingReportParameter( [property: FromHeader] string Login, [property: FromBody] ReportCallingDTO ReportCallingDTO, [property: QueryParam] int FirstNumber, [property: QueryParam] int MaxResult ); protected override IAsyncEnumerable ExecuteReportAsync( GetDeiSourcingReportParameter req, LoginDTO login, CancellationToken ct) => _bll.GetDeiSourcingReportStream(req.FirstNumber, req.MaxResult, req.ReportCallingDTO?.CriteriaDTO, login, ct); protected override async Task> ExecutePagedAsync( GetDeiSourcingReportParameter req, LoginDTO login, CancellationToken ct) { var result = await _bll.GetDeiSourcingReport( req.FirstNumber, req.MaxResult, req.ReportCallingDTO?.CriteriaDTO, login, ct).ConfigureAwait(false); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.NOT_REQUIRED, login).ConfigureAwait(false); } } }