feat(workspace): interview and follow-up workflow
Phase 5.5. Completes the lifecycle after submission: prepare, communicate, chase. Interview preparation gets a durable, user-owned store. There were already two per-application AI stores, InterviewPrepNote and AiWorkspaceNote, but both are caches that regenerate when their context signature changes — anything a user typed into them would eventually be overwritten. InterviewPrepItem is the side nothing regenerates, covering company research, technical notes, behavioural answers, STAR examples and the user's own questions in one table, because those categories differ only by label and adding one must not need a migration. Each item records whether the user wrote it or accepted a suggestion, and an IsPrepared flag makes the section double as the preparation checklist. Generation stays in the existing AiWorkspaceService "interview" module, appended to AiInteraction as before. A suggestion is history until the user adds it as a prep item; opening the section generates nothing. Follow-up reuses what exists rather than adding a tracker. The date is JobApplication.FollowUpAt, the same field RulesEngine and the reminder hosted service already act on, so reminders keep working with no new wiring. The task stays an ApplicationChecklistItem in the follow-up category — the section counts open tasks without owning them. The record is a FollowUpSet JobEvent, the same type the rest of the app emits. Communication is untouched: Correspondence already owns recruiter contacts, history and notes, and the workspace already mounted it. The timeline interpreter learned five more types — InterviewScheduled, InterviewCompleted and OfferReceived as milestones, FollowUpCreated and FollowUpCompleted as routine, deliberately outside the milestone spine so it stays a summary of what actually happened. JobEvent remains the history source. InterviewPrepItems is reconciler-owned with a no-op migration, guarded on JobApplications, and verified on a fresh MariaDB 11: int AUTO_INCREMENT primary key, varchar owner and title, tinyint flag, datetime(6), composite index inside the key limit. 371 backend tests, 128 frontend tests, Release build and the production build all pass locally. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
using JobTrackerApi.Models;
|
||||
using JobTrackerApi.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace JobTrackerApi.Controllers;
|
||||
|
||||
// Phase 5.5 — Interview preparation and follow-up.
|
||||
//
|
||||
// Prep content is the user's; AI suggestions come from the existing /api/jobapplications/{id}/ai
|
||||
// routes and only reach here once the user accepts one (POST with source "ai"). Communication stays
|
||||
// entirely on the existing Correspondence routes — there is no messaging endpoint here.
|
||||
// docs/architecture/application-workspace.md.
|
||||
[ApiController]
|
||||
[Route("api/jobapplications/{jobId:int}")]
|
||||
[Authorize(AuthenticationSchemes = "local")]
|
||||
public sealed class InterviewPrepController : ControllerBase
|
||||
{
|
||||
public sealed record SetFollowUpRequest(DateTime? FollowUpAt, string? NextAction);
|
||||
|
||||
private readonly UserManager<ApplicationUser> _users;
|
||||
private readonly IInterviewPrepService _prep;
|
||||
|
||||
public InterviewPrepController(UserManager<ApplicationUser> users, IInterviewPrepService prep)
|
||||
{
|
||||
_users = users;
|
||||
_prep = prep;
|
||||
}
|
||||
|
||||
[HttpGet("interview-prep")]
|
||||
public async Task<ActionResult<InterviewPrepBoardDto>> Get(int jobId, CancellationToken ct)
|
||||
{
|
||||
var userId = await CurrentUserIdAsync();
|
||||
if (userId is null) return Unauthorized();
|
||||
var result = await _prep.GetAsync(userId, jobId, ct);
|
||||
return result is null ? NotFound() : Ok(result);
|
||||
}
|
||||
|
||||
[HttpPost("interview-prep")]
|
||||
public async Task<ActionResult<InterviewPrepItemDto>> Add(int jobId, [FromBody] InterviewPrepInput input, CancellationToken ct)
|
||||
{
|
||||
var userId = await CurrentUserIdAsync();
|
||||
if (userId is null) return Unauthorized();
|
||||
if (string.IsNullOrWhiteSpace(input?.Title)) return BadRequest("Title is required.");
|
||||
var created = await _prep.AddAsync(userId, jobId, input, ct);
|
||||
return created is null ? NotFound() : Ok(created);
|
||||
}
|
||||
|
||||
[HttpPatch("interview-prep/{itemId:int}")]
|
||||
public async Task<ActionResult<InterviewPrepItemDto>> Update(int jobId, int itemId, [FromBody] InterviewPrepInput input, CancellationToken ct)
|
||||
{
|
||||
var userId = await CurrentUserIdAsync();
|
||||
if (userId is null) return Unauthorized();
|
||||
var updated = await _prep.UpdateAsync(userId, jobId, itemId, input, ct);
|
||||
return updated is null ? NotFound() : Ok(updated);
|
||||
}
|
||||
|
||||
[HttpDelete("interview-prep/{itemId:int}")]
|
||||
public async Task<IActionResult> Delete(int jobId, int itemId, CancellationToken ct)
|
||||
{
|
||||
var userId = await CurrentUserIdAsync();
|
||||
if (userId is null) return Unauthorized();
|
||||
return await _prep.DeleteAsync(userId, jobId, itemId, ct) ? NoContent() : NotFound();
|
||||
}
|
||||
|
||||
[HttpGet("follow-up")]
|
||||
public async Task<ActionResult<FollowUpDto>> GetFollowUp(int jobId, CancellationToken ct)
|
||||
{
|
||||
var userId = await CurrentUserIdAsync();
|
||||
if (userId is null) return Unauthorized();
|
||||
var result = await _prep.GetFollowUpAsync(userId, jobId, ct);
|
||||
return result is null ? NotFound() : Ok(result);
|
||||
}
|
||||
|
||||
[HttpPut("follow-up")]
|
||||
public async Task<ActionResult<FollowUpDto>> SetFollowUp(int jobId, [FromBody] SetFollowUpRequest request, CancellationToken ct)
|
||||
{
|
||||
var userId = await CurrentUserIdAsync();
|
||||
if (userId is null) return Unauthorized();
|
||||
var result = await _prep.SetFollowUpAsync(userId, jobId, request?.FollowUpAt, request?.NextAction, ct);
|
||||
return result is null ? NotFound() : Ok(result);
|
||||
}
|
||||
|
||||
private async Task<string?> CurrentUserIdAsync() => (await _users.GetUserAsync(User))?.Id;
|
||||
}
|
||||
Reference in New Issue
Block a user