Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6e93d97
docs: RFC for application status model and migration (#108)
claude Nov 30, 2026
1a909a4
feat(applications): add stage/outcome/waitingOn columns alongside leg…
claude Nov 30, 2026
6b28269
feat(applications): map legacy status values to stage/outcome/waitingOn
claude Nov 30, 2026
dfa9717
fix(scheduler): stop overwriting closed, archived and draft applications
claude Nov 30, 2026
ffa7c05
feat(applications): backfill stage/outcome from legacy status on startup
claude Nov 30, 2026
f74901d
feat(applications): dual-write stage/outcome on status changes and ex…
claude Nov 30, 2026
5669561
docs(mcp): give each status a meaning and one rule for RH; fix Swagge…
claude Nov 30, 2026
f335e02
docs: phase 1 implementation plan for the status model (#108)
claude Nov 30, 2026
3825de0
Merge remote-tracking branch 'origin/main' into hugo/intelligent-wozn…
claude Nov 30, 2026
878795a
fix: keep ApplicationStatus enum, now used by assistant status aliase…
claude Nov 30, 2026
8d1d254
docs: design for the stage/outcome cutover (#108)
claude Dec 1, 2026
fddbb20
docs: backend and frontend plans for the stage/outcome cutover (#108)
claude Dec 1, 2026
66403c8
refactor(status): best-effort legacy conversion, drop NEEDS_REVIEW
claude Dec 1, 2026
046e4ab
feat(applications): resolve stage on every write; legacy records need…
claude Dec 1, 2026
234f2da
feat(applications): calculated ghosting replaces the nightly Ghosting…
claude Dec 1, 2026
d112e1c
feat(applications): dashboard, interview metrics and gamification rea…
claude Dec 1, 2026
590805e
feat(applications): filters, search and export use stage/outcome; leg…
claude Dec 1, 2026
ade9911
test: model drafts with the draft stage in the reminder IT
claude Dec 1, 2026
b60daab
feat(assistant): queries and aggregations use the stage/outcome phase…
claude Dec 1, 2026
a2398f9
feat(mcp): stage catalog, Update-Application-Stage and stage-aware to…
claude Dec 1, 2026
1c9c299
chore(dev): fake data seeder writes the stage model
claude Dec 1, 2026
dbbe033
fix(applications): echoed legacy status never reopens or regresses a …
claude Dec 1, 2026
6ecb411
test: clean webauthn challenges before deleting users in ApplicationC…
claude Dec 1, 2026
5c210a6
fix(status): Ghosting over a closing status converts even without a date
claude Dec 3, 2026
7be60b4
Merge branch 'hugo/intelligent-wozniak-krhlwh' of https://github.com/…
claude Dec 3, 2026
aec6353
fix(data): restore application dates of drafts the old nightly job ex…
claude Dec 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,16 @@ private static Optional<StageState> rejected(String previous, LocalDate applicat
}

private static Optional<StageState> ghosting(String previous, LocalDate applicationDate) {
if (applicationDate == null) {
return Optional.empty();
}
// A closing status under Ghosting decides the conversion on its own, with or without a date.
if (previous != null && REJECTED.contains(previous)) {
return rejected(null, applicationDate);
}
if (previous != null && (HIRED.contains(previous) || WITHDRAWN.contains(previous))) {
return closingOrOpen(previous, applicationDate);
}
if (applicationDate == null) {
return Optional.empty();
}
ApplicationStage last = previous == null ? null : openStage(previous, applicationDate);
return Optional.of(new StageState(last != null ? last : ApplicationStage.APPLIED, null, WaitingOn.COMPANY));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- Ghosting over a closing status without an application date was left unconverted by mistake.
-- Clearing the marker makes the startup backfill attempt these rows again; rows that still
-- cannot be converted get their legacy value back. Converted rows are untouched.
UPDATE job_applications
SET legacy_status = NULL
WHERE stage IS NULL
AND legacy_status IS NOT NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
-- One-off data repair approved by the maintainer (issue #108 follow-up, 2026-12-03).
--
-- Before the stage cutover, applications created without a status were stored as drafts and the API
-- cleared their application date; the old nightly job then turned them into "Rejected" and later into
-- "Ghosting". They were real applications, registered on the day they were sent, so the creation day
-- is used as the application date and they become open applications waiting on the company.
--
-- Only rows with that exact shape are touched: no application date, no outcome chosen since the
-- cutover, and either "Rejected" with no previous status or "Ghosting" over "Rejected".
-- Missed deadlines (Tarde demais) and other legacy rows are left alone. updated_at is not changed.
-- The previous values are kept in application_date_repair_backup_20261203 for audit and rollback.

CREATE TABLE IF NOT EXISTS application_date_repair_backup_20261203 AS
SELECT id, status, previous_status, stage, outcome, waiting_on, legacy_status, application_date,
to_send_later, created_at, updated_at, NOW() AS backed_up_at
FROM job_applications
WHERE FALSE;

CREATE TEMPORARY TABLE application_date_repair_targets ON COMMIT DROP AS
SELECT id
FROM job_applications
WHERE application_date IS NULL
AND outcome IS NULL
AND (stage IS NULL OR stage = 'DRAFT')
AND (
(LOWER(TRIM(status)) IN ('rejected', 'rejeitado') AND previous_status IS NULL)
OR (LOWER(TRIM(status)) = 'ghosting' AND LOWER(TRIM(previous_status)) IN ('rejected', 'rejeitado'))
);

INSERT INTO application_date_repair_backup_20261203
SELECT j.id, j.status, j.previous_status, j.stage, j.outcome, j.waiting_on, j.legacy_status, j.application_date,
j.to_send_later, j.created_at, j.updated_at, NOW()
FROM job_applications j
JOIN application_date_repair_targets t ON t.id = j.id
WHERE NOT EXISTS (SELECT 1 FROM application_date_repair_backup_20261203 b WHERE b.id = j.id);

UPDATE job_applications j
SET application_date = j.created_at::date,
stage = 'APPLIED',
outcome = NULL,
waiting_on = 'COMPANY',
to_send_later = FALSE,
legacy_status = j.status
FROM application_date_repair_targets t
WHERE t.id = j.id;
115 changes: 115 additions & 0 deletions src/test/java/com/jobtracker/integration/ExpiredDraftDateRepairIT.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package com.jobtracker.integration;

import com.jobtracker.entity.User;
import com.jobtracker.repository.UserRepository;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.jdbc.core.JdbcTemplate;

import java.nio.charset.StandardCharsets;
import java.sql.Date;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Map;
import java.util.UUID;

import static org.assertj.core.api.Assertions.assertThat;

/** Runs the V42 data repair against real rows shaped like the production ones it targets. */
class ExpiredDraftDateRepairIT extends AbstractIntegrationTest {

private static final LocalDateTime CREATED = LocalDateTime.of(2026, 10, 25, 14, 30);
private static final LocalDateTime UPDATED = LocalDateTime.of(2026, 11, 2, 0, 0);

@Autowired private JdbcTemplate jdbc;
@Autowired private UserRepository userRepository;

private UUID userId;

@BeforeEach
void setUp() {
jdbc.update("DROP TABLE IF EXISTS application_date_repair_backup_20261203");
jdbc.update("DELETE FROM job_applications");
User user = new User();
user.setName("Repair");
user.setEmail("repair-" + UUID.randomUUID() + "@example.com");
user.setPasswordHash("x");
userId = userRepository.save(user).getId();
}

@Test
void expiredDraftsGetTheirCreationDayAsApplicationDateAndAreBackedUp() throws Exception {
UUID rejectedDraft = insert("Rejected", null, "DRAFT", null, "Rejected");
UUID ghostingOverRejected = insert("Ghosting", "Rejected", null, null, "Ghosting");
UUID missedDeadline = insert("Ghosting", "TARDE_DEMAIS", null, null, "Ghosting");
UUID ghostingOverGhosting = insert("Ghosting", "GHOSTING", null, null, "Ghosting");
UUID plainDraft = insert(null, null, "DRAFT", null, "TO_SEND_LATER");
UUID rejectedWithDate = insert("Rejected", null, "APPLIED", LocalDate.of(2026, 9, 1), "Rejected");

runRepair();

for (UUID repaired : new UUID[]{rejectedDraft, ghostingOverRejected}) {
Map<String, Object> row = row(repaired);
assertThat(row.get("application_date")).isEqualTo(Date.valueOf(CREATED.toLocalDate()));
assertThat(row.get("stage")).isEqualTo("APPLIED");
assertThat(row.get("outcome")).isNull();
assertThat(row.get("waiting_on")).isEqualTo("COMPANY");
assertThat(row.get("to_send_later")).isEqualTo(false);
assertThat(row.get("updated_at")).isEqualTo(Timestamp.valueOf(UPDATED));
assertThat(row.get("legacy_status")).isNotNull();
}
assertThat(row(missedDeadline).get("stage")).isNull();
assertThat(row(ghostingOverGhosting).get("stage")).isNull();
assertThat(row(plainDraft).get("stage")).isEqualTo("DRAFT");
assertThat(row(missedDeadline).get("application_date")).isNull();
assertThat(row(ghostingOverGhosting).get("application_date")).isNull();
assertThat(row(plainDraft).get("application_date")).isNull();
assertThat(row(rejectedWithDate).get("application_date")).isEqualTo(Date.valueOf(LocalDate.of(2026, 9, 1)));

assertThat(jdbc.queryForList("SELECT id FROM application_date_repair_backup_20261203", UUID.class))
.containsExactlyInAnyOrder(rejectedDraft, ghostingOverRejected);
Map<String, Object> backup = jdbc.queryForMap(
"SELECT stage, application_date, to_send_later FROM application_date_repair_backup_20261203 WHERE id = ?",
rejectedDraft);
assertThat(backup.get("stage")).isEqualTo("DRAFT");
assertThat(backup.get("application_date")).isNull();
}

@Test
void runningTheRepairTwiceChangesNothingMore() throws Exception {
UUID rejectedDraft = insert("Rejected", null, "DRAFT", null, "Rejected");
runRepair();
Map<String, Object> first = row(rejectedDraft);

runRepair();

assertThat(row(rejectedDraft)).isEqualTo(first);
assertThat(jdbc.queryForObject("SELECT COUNT(*) FROM application_date_repair_backup_20261203", Long.class))
.isEqualTo(1L);
}

private void runRepair() throws Exception {
String sql = new ClassPathResource("db/migration/postgresql/V42__repair_expired_draft_application_dates.sql")
.getContentAsString(StandardCharsets.UTF_8);
jdbc.execute(sql);
}

private UUID insert(String status, String previous, String stage, LocalDate date, String legacy) {
UUID id = UUID.randomUUID();
jdbc.update("""
INSERT INTO job_applications (id, user_id, vacancy_name, organization, status, previous_status, stage,
legacy_status, application_date, to_send_later, archived, rh_accepted_connection,
interview_scheduled, recruiter_dm_reminder_enabled, interview_count, created_at, updated_at)
VALUES (?, ?, 'Engineer', 'Acme', ?, ?, ?, ?, ?, ?, false, false, false, false, 0, ?, ?)""",
id, userId, status, previous, stage, legacy, date == null ? null : Date.valueOf(date),
"DRAFT".equals(stage), Timestamp.valueOf(CREATED), Timestamp.valueOf(UPDATED));
return id;
}

private Map<String, Object> row(UUID id) {
return jdbc.queryForMap("SELECT * FROM job_applications WHERE id = ?", id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@ void ghostingWithoutAMappablePreviousFallsBackToApplied(String previous) {
assertState(map("Ghosting", previous), APPLIED, null, COMPANY);
}

@Test
void ghostingOverAClosingStatusWithoutDateStillAppliesTheClosingRule() {
// Production rows: drafts the old nightly job moved to Rejected/Tarde demais and then to Ghosting.
assertState(LegacyStatusMapper.map("Ghosting", "TARDE_DEMAIS", false, null), DRAFT, WITHDREW, null);
assertState(LegacyStatusMapper.map("Ghosting", "Rejected", false, null), DRAFT, null, null);
}

@Test
void ghostingOverGhostingWithoutDateIsNotConverted() {
assertThat(LegacyStatusMapper.map("Ghosting", "GHOSTING", false, null)).isEmpty();
}

@Test
void ghostingWithoutDateIsNotConverted() {
assertThat(LegacyStatusMapper.map("Ghosting", null, false, null)).isEmpty();
Expand Down
Loading