fix(app): harden account and workflow state
This commit is contained in:
@@ -473,6 +473,7 @@ Canonical profile:
|
||||
[FromQuery] int? companyId = null,
|
||||
[FromQuery] string? location = null,
|
||||
[FromQuery] bool needsFollowUp = false,
|
||||
[FromQuery] string? readiness = null,
|
||||
[FromQuery] bool includeDeleted = false,
|
||||
[FromQuery] bool deletedOnly = false,
|
||||
[FromQuery] string? sortBy = null,
|
||||
@@ -482,6 +483,9 @@ Canonical profile:
|
||||
{
|
||||
if (page < 1) page = 1;
|
||||
if (pageSize is not (15 or 20 or 25)) pageSize = 15;
|
||||
var readinessFilter = (readiness ?? string.Empty).Trim().ToLowerInvariant();
|
||||
if (readinessFilter is not ("" or "needs-work" or "interview"))
|
||||
return BadRequest("Readiness must be 'needs-work' or 'interview'.");
|
||||
|
||||
var query = _db.JobApplications
|
||||
.AsNoTracking()
|
||||
@@ -542,16 +546,25 @@ Canonical profile:
|
||||
var dirDesc = string.Equals(sortDir, "desc", StringComparison.OrdinalIgnoreCase);
|
||||
var key = (sortBy ?? "dateApplied").Trim();
|
||||
|
||||
if (needsFollowUp)
|
||||
if (needsFollowUp || readinessFilter.Length > 0)
|
||||
{
|
||||
// NeedsFollowUp depends on rules + last correspondence date; evaluate in memory so filtering is correct.
|
||||
// Both filters depend on rule evaluation and workflow signals that include normalized
|
||||
// note content, so evaluate before pagination to keep totals/pages correct.
|
||||
var pre = await query.ToListAsync(cancellationToken);
|
||||
var filtered = new List<JobApplication>();
|
||||
foreach (var j in pre)
|
||||
{
|
||||
lastMsg.TryGetValue(j.Id, out var lm);
|
||||
var d = RulesEngine.Evaluate(settings, j, now, lm);
|
||||
if (d.NeedsFollowUp) filtered.Add(j);
|
||||
var signal = BuildWorkflowSignal(j, d);
|
||||
var matchesFollowUp = !needsFollowUp || d.NeedsFollowUp;
|
||||
var matchesReadiness = readinessFilter switch
|
||||
{
|
||||
"interview" => signal.NeedsInterviewPrep,
|
||||
"needs-work" => signal.HasPackageGap || signal.NeedsInterviewPrep,
|
||||
_ => true,
|
||||
};
|
||||
if (matchesFollowUp && matchesReadiness) filtered.Add(j);
|
||||
}
|
||||
|
||||
filtered = key switch
|
||||
|
||||
Reference in New Issue
Block a user