Skip to content

Bugfix/job application email identifier bugs - #89

Merged
SagiEv merged 2 commits into
mainfrom
bugfix/job-application-email-identifier-bugs
Sep 19, 2026
Merged

SagiEv merged 2 commits into
mainfrom
bugfix/job-application-email-identifier-bugs

Conversation

@SagiEv

@SagiEv SagiEv commented Sep 19, 2026

Copy link
Copy Markdown
Owner

Fix Application Status Lifecycle and History Audit Trail

Overview

This PR standardizes system statuses, fixes background polling bugs that incorrectly matched emails to terminal applications, and bulletproofs the application history audit trail. Previously, automated email polling was silently updating application statuses directly in the database without logging history, leading to desynchronized activity logs and incorrect "Last Updated" dates.

Changes Made

1. Status Standardization

  • Removed all usages of the deprecated follow_up status. It is now functionally treated as Applied.
  • Enforced strict Title Case for system statuses across the backend (Applied, Screening, Assessment, Interviewing, Offer, Rejected) to match the exact strings expected by the UI.

2. Bulletproofed History Logging

  • Mail Poller Refactor: Modified mail-poller.service.js to call applicationsService.updateApplication instead of performing direct database updates (applicationRepo.update). This ensures that status changes triggered by incoming emails properly insert new application_history events.
  • Application Creation Logic: Updated applications.service.js to explicitly register Application Added events via applicationHistoryService.logChange when applications are created (single or bulk imports).

3. Fixed Email Matching for Terminal Applications

  • Filtered Terminal Applications: Modified mail-poller.service.js to filter out terminal applications (Rejected, Offer, Hired, Withdrawn, Ignored) before classifying emails. This resolves a bug where a new rejection email would incorrectly match an older, already-rejected application for the same company, overwriting its event_date.

4. Database Migrations & Resync Scripts

  • Created and ran fix_follow_up_status.js to migrate existing follow_up statuses to Applied in the DB.
  • Created and ran sync_applications_history.js to fix corrupted database state by fetching the latest application_history event for each application and resyncing the status, stage, and date fields in the applications table.

5. Testing Infrastructure Updates

  • Updated integration tests (email-pipeline.integration.test.js, application-lifecycle.integration.test.js) and unit tests to adhere strictly to the Title Case constraint.
  • Upgraded the Supabase sandbox in setup.integration.js to support chained, sequential .select().single() mock responses to handle complex repository queries during testing.

Verification

  • ✅ Unit tests passed (npm test locally).
  • ✅ Integration tests verified that automated email state transitions succeed and populate the application_history table correctly.
  • ✅ Data resync script executed successfully (corrected 67 out-of-sync applications).

@SagiEv SagiEv added bug Something isn't working enhancement New feature or request labels Sep 19, 2026
@SagiEv SagiEv linked an issue Sep 19, 2026 that may be closed by this pull request
@vercel

vercel Bot commented Sep 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
job-pilot Ready Ready Preview Sep 19, 2026 6:06pm UTC

@SagiEv
SagiEv merged commit c8ab376 into main Sep 19, 2026
6 checks passed

This branch was successfully deployed

1 active deployment
Preview — 2e82c659 Deployed Sep 19, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix Job Application Email Identifier Bugs

1 participant