Skip to content

fix(analytics): attribute applications to original applied date instead of status update date - #104

Merged
SagiEv merged 2 commits into
mainfrom
fix/analytics-monthly-volume-applied-date
Dec 1, 2026
Merged

SagiEv merged 2 commits into
mainfrom
fix/analytics-monthly-volume-applied-date

Conversation

@SagiEv

@SagiEv SagiEv commented Nov 29, 2026

Copy link
Copy Markdown
Owner

Problem

Updating an older application's status (e.g., marking a ghosted application as Ignored) caused it to be counted as a newly applied application in the current month on the Monthly Volume chart and in the This Week / This Month KPI cards.

Root Cause

  1. applications.service.js (updateApplication) overwrote applications.date with latestEvent.event_date on every status/stage update.
  2. Analytics (calculateMonthlyVolume and AnalyticsPage) grouped applied counts by app.DATE, shifting previously applied jobs into the month of their latest status update.

Changes

Backend (Node.js)

  • backend/services/applications.service.js
    • Removed updateData.date overwrite in updateApplication() so status/stage updates preserve the original applications.date (while last_activity_date continues tracking the latest history event).
    • Updated getAllApplications() to derive applied_date (YYYY-MM-DD) from already-fetched application_history rows (no extra DB query): prefers the earliest 'Application Added' event, falls back to the earliest valid date across history/app.date/app.created_at for legacy rows without 'Application Added', and finally app.date || app.created_at.

Frontend (React)

  • frontend/src/queries/queryDefinitions.js
    • Mapped APPLIED_DATE: row.applied_date || row.date || '' in fromDbApplication().
  • frontend/src/utils/analyticsCalculations.js
    • Updated calculateMonthlyVolume() to bucket "Applications Applied" by APPLIED_DATE || applied_date || DATE || date.
  • frontend/src/pages/AnalyticsPage.jsx
    • Updated thisWeek, thisMonth, and lastMonth KPI calculations to use APPLIED_DATE || DATE for consistency with Monthly Volume.

Database / Legacy Data

  • supabase/migrations/20261129000000_backfill_applications_date.sql
    • Added an idempotent backfill migration restoring applications.date from application_history (Application Added first, else earliest event_date) only when applications.date is NULL or later than the earliest recorded history date.
    • Existing records are also immediately corrected at read time via applied_date even prior to running the migration.

Testing

  • Backend (npm test): 53/53 suites, 426/426 tests passed.
    • Added unit tests in backend/tests/applications.status.test.js (verifies Ignored status update does not overwrite date) and backend/tests/services/applications.service.test.js (verifies applied_date derivation for both standard and legacy rows).
  • Frontend (npx vitest run src/utils/__tests__/analyticsCalculations.test.js): 22/22 tests passed.
    • Added unit test verifying Ignored applications are counted in their original APPLIED_DATE month rather than the status update month.
    • Fixed a date-sensitive flake in an existing ghosting rate test by using relative dates instead of a hardcoded 2026-11-01.

@vercel

vercel Bot commented Nov 29, 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 Nov 29, 2026 12:32pm UTC

@SagiEv
SagiEv merged commit b45ae89 into main Dec 1, 2026
6 checks passed

This branch was successfully deployed

1 active deployment
Preview — 87d6dbd4 Deployed Nov 29, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant