refactor(jobs): centralize status lifecycle
This commit is contained in:
@@ -14,6 +14,26 @@ namespace JobTrackerApi.Services;
|
||||
// docs/architecture/application-workspace.md.
|
||||
public static class JobLifecycleEvents
|
||||
{
|
||||
/// <summary>
|
||||
/// Keeps the application date aligned with the pipeline stage and preserves a cleared date in
|
||||
/// the event ledger. Both full-record and status-only updates use this single boundary.
|
||||
/// </summary>
|
||||
public static void SyncAppliedDateWithHistory(JobTrackerContext db, JobApplication job, DateTime at)
|
||||
{
|
||||
var cleared = JobPipeline.SyncAppliedDate(job, at);
|
||||
if (cleared is null) return;
|
||||
|
||||
db.JobEvents.Add(new JobEvent
|
||||
{
|
||||
JobApplicationId = job.Id,
|
||||
Type = JobPipeline.AppliedDateClearedEvent,
|
||||
OldValue = cleared.Value.ToString("o"),
|
||||
NewValue = null,
|
||||
Note = $"Moved to {job.Status} before applying; application date cleared.",
|
||||
At = at,
|
||||
});
|
||||
}
|
||||
|
||||
// Records the status change itself plus, when the transition warrants it, one lifecycle event.
|
||||
// Replaces the hand-written StatusChanged block at each call site.
|
||||
public static void RecordStatusChange(JobTrackerContext db, JobApplication job, string? oldStatus, DateTime at)
|
||||
|
||||
Reference in New Issue
Block a user