using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.DTO.Report; using GB5Shared.FastEndPoint; using RecruitmentBLL.Reports.JobAdSpendPerformance; using RecruitmentDAL.DTO.Reports; using static GB5Shared.GB5Constant.Constant; namespace RecruitmentSL.EndPoints.RecruitmentReports { // Phase 6 analytics (see /Users/venkatv/.claude/plans/can-you-check-the-precious-sunbeam.md, // Phase 6) — job-ad spend performance report. Row grain: one row per // (JobRequisitionId, JobBoardName, ChannelType, CurrencyCode) — see // JobAdSpendPerformanceDTO's doc comment for why this is a new, separate report from // GetCandidateSourceQuality rather than an extension of it. public class GetJobAdSpendPerformance : BaseReportEndpoint { private readonly IJobAdSpendPerformanceBLL _bll; public GetJobAdSpendPerformance(IJobAdSpendPerformanceBLL bll) { _bll = bll; } public override void Configure() { Post("/RecruitmentReports/GetJobAdSpendPerformance"); AllowAnonymous(); } public record GetJobAdSpendPerformanceParameter( [property: FromHeader] string Login, [property: FromBody] ReportCallingDTO ReportCallingDTO, [property: QueryParam] int FirstNumber, [property: QueryParam] int MaxResult, [property: QueryParam] int MenuId ); protected override IAsyncEnumerable ExecuteReportAsync( GetJobAdSpendPerformanceParameter req, LoginDTO login, CancellationToken ct) => _bll.GetJobAdSpendPerformanceStream( req.FirstNumber, req.MaxResult, req.ReportCallingDTO?.CriteriaDTO, login, ct); // Real SQL-level paging — JobAdSpendPerformanceQB drives OFFSET/FETCH, so the deliberately // weak default ExecutePagedAsync (500-row stream cap) is overridden per CLAUDE.md. protected override async Task> ExecutePagedAsync( GetJobAdSpendPerformanceParameter req, LoginDTO login, CancellationToken ct) { var result = await _bll.GetJobAdSpendPerformance( req.FirstNumber, req.MaxResult, req.ReportCallingDTO?.CriteriaDTO, login, ct).ConfigureAwait(false); // Financial/spend data — NOT_REQUIRED per CLAUDE.md's caching rules. return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.NOT_REQUIRED, login); } } }