From 7089ec637ce64afe0e59af69fe08f457ddcb51e1 Mon Sep 17 00:00:00 2001 From: Nithin Date: Sun, 30 Aug 2026 06:07:13 -0400 Subject: [PATCH] fix(coverage): report only current source health as live --- src/fortune_intel/storage/summary_ops.py | 9 +++++++++ src/fortune_intel/web/app.js | 2 +- src/fortune_intel/web/companies.js | 10 ++++++++-- tests/test_api.py | 1 + 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/fortune_intel/storage/summary_ops.py b/src/fortune_intel/storage/summary_ops.py index 7425ddd..7741223 100644 --- a/src/fortune_intel/storage/summary_ops.py +++ b/src/fortune_intel/storage/summary_ops.py @@ -127,6 +127,14 @@ def overview(self, *, include_synthetic: bool = True, us_only: bool = False) -> WHERE s.enabled = 1 AND s.last_success_at IS NOT NULL AND (? = 1 OR source_company.is_synthetic = 0) ) AS companies_with_successful_job_fetches, + ( + SELECT COUNT(DISTINCT s.company_id) + FROM career_sources s JOIN companies source_company + ON source_company.id = s.company_id + WHERE s.enabled = 1 AND s.last_success_at IS NOT NULL + AND s.consecutive_failures < 2 + AND (? = 1 OR source_company.is_synthetic = 0) + ) AS companies_with_current_job_fetches, COUNT(CASE WHEN j.status = 'active' AND (? = 1 OR c.is_synthetic = 0) AND (? = 0 OR j.us_eligibility = 'eligible') THEN 1 END) AS active_jobs, COUNT(CASE WHEN j.status = 'active' AND j.sponsorship_tier IN ('A','B','C','E') @@ -140,6 +148,7 @@ def overview(self, *, include_synthetic: bool = True, us_only: bool = False) -> int(include_synthetic), int(include_synthetic), int(include_synthetic), + int(include_synthetic), int(us_only), int(include_synthetic), int(us_only), diff --git a/src/fortune_intel/web/app.js b/src/fortune_intel/web/app.js index e4bda86..317d505 100644 --- a/src/fortune_intel/web/app.js +++ b/src/fortune_intel/web/app.js @@ -94,7 +94,7 @@ async function loadStats() { document.querySelector("#stat-jobs").textContent = Number(stats.active_jobs).toLocaleString(); document.querySelector("#stat-companies").textContent = Number(stats.companies).toLocaleString(); document.querySelector("#stat-fetching-companies").textContent = Number( - stats.companies_with_successful_job_fetches, + stats.companies_with_current_job_fetches, ).toLocaleString(); document.querySelector("#stat-h1b").textContent = Number(stats.h1b_employers).toLocaleString(); document.querySelector("#stat-evidence").textContent = Number(stats.jobs_with_evidence).toLocaleString(); diff --git a/src/fortune_intel/web/companies.js b/src/fortune_intel/web/companies.js index d932af9..e2e3e35 100644 --- a/src/fortune_intel/web/companies.js +++ b/src/fortune_intel/web/companies.js @@ -20,7 +20,7 @@ async function loadCompanies() { const data = await response.json(); if (requestId !== latestRequest) return; total = data.total; - const covered = data.items.filter((company) => company.source_last_success_at).length; + const covered = data.items.filter((company) => company.coverage_disposition === "supported").length; const rows = data.items.map((company) => { const row = document.createElement("tr"); const name = document.createElement("a"); @@ -32,7 +32,13 @@ async function loadCompanies() { nameCell, cell(Number(company.active_jobs).toLocaleString()), cell(company.source_last_success_at ? new Date(company.source_last_success_at).toLocaleString() : "—"), - cell(company.source_last_success_at ? "Successfully covered" : company.coverage_disposition.replaceAll("_", " ")), + cell( + company.coverage_disposition === "supported" + ? "Current successful source" + : company.coverage_disposition === "stale" + ? "Stale — needs revalidation" + : company.coverage_disposition.replaceAll("_", " "), + ), ); return row; }); diff --git a/tests/test_api.py b/tests/test_api.py index d3837bd..5713928 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -18,6 +18,7 @@ def test_search_api_and_stats(tmp_path): assert stats["active_jobs"] == 4 assert stats["companies"] == 4 assert stats["companies_with_successful_job_fetches"] == 0 + assert stats["companies_with_current_job_fetches"] == 0 assert stats["jobs_with_evidence"] == 3