using System; using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.QueryExecutor; using GB5Shared.Telemetry; using RecruitmentDAL.DTO.Reports; using RecruitmentDAL.Reports; namespace RecruitmentBLL.Reports { // Recruiter workload/productivity dashboard (Phase 5 of the Recruitment build-out plan) — the // operational "what's on my plate" view: open requisitions, pending applications, and // requisitions closed in a date range, grouped by TJOBREQUISITION.ASSIGNEDRECRUITERID. // Live transactional analytics — CacheKeyLevel.NOT_REQUIRED at the endpoint, never cached, per // CLAUDE.md's caching anti-pattern guidance. public class RecruiterWorkloadReportBLL : IRecruiterWorkloadReportBLL { private const int DEFAULT_MAX_RESULT_CAP = 500; private readonly IRecruiterWorkloadReportDAL _dal; public RecruiterWorkloadReportBLL(IRecruiterWorkloadReportDAL dal) { _dal = dal; } public async Task> GetRecruiterWorkload( int firstNumber, int maxResult, CriteriaDTO criteriaDTO, LoginDTO login, CancellationToken ct) { try { GB5Trace.Step("parse-criteria-recruiter-workload", new { firstNumber, maxResult }); var criteria = RecruitmentReportCriteriaParser.Parse(criteriaDTO); var cappedMaxResult = maxResult > 0 ? Math.Min(maxResult, DEFAULT_MAX_RESULT_CAP) : DEFAULT_MAX_RESULT_CAP; GB5Trace.Step("query-recruiter-workload", new { firstNumber, cappedMaxResult }); return await _dal.GetRecruiterWorkload(firstNumber, cappedMaxResult, criteria, login, ct).ConfigureAwait(false); } catch (Exception ex) { GB5Trace.MarkFailed("recruiter-workload-failed", ex); throw; } } public async IAsyncEnumerable GetRecruiterWorkloadStream( int firstNumber, int maxResult, CriteriaDTO criteriaDTO, LoginDTO login, [EnumeratorCancellation] CancellationToken ct) { GB5Trace.Step("stream-recruiter-workload", new { firstNumber, maxResult }); var criteria = RecruitmentReportCriteriaParser.Parse(criteriaDTO); var cappedMaxResult = maxResult > 0 ? Math.Min(maxResult, DEFAULT_MAX_RESULT_CAP) : DEFAULT_MAX_RESULT_CAP; await foreach (var row in _dal.GetRecruiterWorkloadStream(firstNumber, cappedMaxResult, criteria, login, ct).ConfigureAwait(false)) yield return row; } } }