Files
jobtrackingapp/Models/JobApplication.cs
T
cesnimda eac34705e3 feat: Phase 0 foundation — Job entity, expanded pipeline, AI service lockdown, DateApplied history
Unblocks the documented core workflow and closes the AI-service exposure,
without changing existing behaviour.

Job/JobApplication split (additive; see ADR-002):
- New Job entity (the opportunity) with owner-scoped query filter; nullable
  JobApplication.JobId FK. Nothing reads Job yet.
- Migration AddJobEntityAndProspectStages, hand-edited to drop reconciler-owned
  tables the scaffolder re-emitted; verified against the real dev DB.

Pipeline: 10 internal stages across three concerns kept separate —
PipelineStage (workflow) / PipelineGroup (UI: NotApplied/Active/Closed) /
PipelineCategory (analytics). Adds Saved/Interested/Preparing/Withdrawn;
keeps Waiting and Ghosted. Kanban shows 3 grouped columns; cards keep a stage
chip and full transitions; drag applies only safe transitions (never infers
Ghosted/Withdrawn).

DateApplied nullable + SavedAt. Cleared when leaving Applied so analytics stay
accurate; the discarded date is preserved as an AppliedDateCleared JobEvent.

AI service lockdown: no host port; private ai_internal network (backend is the
only other member); X-Ai-Service-Token required on all non-/health endpoints;
AI_SERVICE_TOKEN mandatory via compose. Verified backend-only against the live
stack.

Also carries two pre-existing working-tree files (views/ProfilePage.tsx,
views/CareerWorkspacePage.tsx) so the tree is clean for the branch integration.

Tests: +40 backend (247 total), +5 sidecar (16), +15 frontend.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-17 17:05:25 +02:00

90 lines
4.0 KiB
C#

using System;
namespace JobTrackerApi.Models
{
public class JobApplication
{
public int Id { get; set; }
public string? OwnerUserId { get; set; }
public string JobTitle { get; set; } = "";
public int CompanyId { get; set; }
public Company Company { get; set; } = null!;
// The opportunity this application is for. Nullable and unused for now: Phase 0 added the
// Job entity additively and JobApplication still owns the opportunity columns below.
// See Models/Job.cs and docs/decisions/ADR-002-job-application-model.md.
public int? JobId { get; set; }
public Job? Job { get; set; }
public string Status { get; set; } = "Applied";
/// <summary>
/// When the user submitted the application. Null while the job is still in a pre-application
/// (Prospect) stage — Saved/Interested/Preparing — because nothing has been submitted yet.
/// Callers must not synthesise a date for unapplied jobs: a fake DateApplied feeds the
/// follow-up/ghosting rules and the applied-volume analytics.
/// </summary>
public DateTime? DateApplied { get; set; }
/// <summary>When the user first captured this job. Always set.</summary>
public DateTime SavedAt { get; set; } = DateTime.UtcNow;
public string? Location { get; set; }
public string? Salary { get; set; }
// Structured salary; the free-text Salary field is kept for display/back-compat.
public decimal? SalaryMin { get; set; }
public decimal? SalaryMax { get; set; }
public string? SalaryCurrency { get; set; } // e.g. "NOK", "GBP", "EUR"
public string? SalaryPeriod { get; set; } // "year" | "month" | "hour"
public string? NextAction { get; set; }
public DateTime? FollowUpAt { get; set; }
public DateTime? FeedbackRequestedAt { get; set; }
public string? RecruiterMessageDraft { get; set; }
// Attachment checklist. Derived from Attachment rows, not directly settable by API
// consumers -- see AttachmentsController.RecomputeAttachmentFlagsAsync, the single place
// these are written, so they can't drift from what's actually attached.
public bool HasResume { get; set; } = false;
public bool HasCoverLetter { get; set; } = false;
public bool HasPortfolio { get; set; } = false;
public bool HasOtherAttachment { get; set; } = false;
// Soft delete: hide from default queries without losing history.
public bool IsDeleted { get; set; } = false;
public DateTime? DeletedAt { get; set; }
public bool ResponseReceived { get; set; } = false;
public DateTime? ResponseDate { get; set; }
public string? Notes { get; set; }
public string? CoverLetterText { get; set; }
public string? JobUrl { get; set; }
// Imported job content
public string? Description { get; set; }
public string? TranslatedDescription { get; set; }
public string? DescriptionLanguage { get; set; } // "en", "no", ...
public string? Tags { get; set; } // JSON array string, e.g. ["Azure","Docker"]
public DateTime? Deadline { get; set; }
// Short summary generated at creation time and persisted to avoid repeated model calls.
public string? ShortSummary { get; set; }
public string? TailoredCvText { get; set; }
public DateTime? TailoredCvUpdatedAt { get; set; }
public DateTime? LastReminderEmailSentAt { get; set; }
public TailoredCvDraft? TailoredCvDraft { get; set; }
public List<Correspondence> Messages { get; set; } = new();
public List<Attachment> Attachments { get; set; } = new();
public List<JobEvent> Events { get; set; } = new();
/// <summary>
/// Days since the application was submitted. Null for pre-application (Prospect) stages:
/// with no DateApplied there is no elapsed time to report, and 0 would read as
/// "applied today".
/// </summary>
public int? DaysSince => DateApplied is null
? null
: ((ResponseReceived ? (ResponseDate ?? DateTime.UtcNow) : DateTime.UtcNow) - DateApplied.Value.ToUniversalTime()).Days;
}
}