Add rescoring and a posting-date order to the leads inbox
Test and deploy / test (push) Successful in 1m56s
Test and deploy / deploy (push) Successful in 1m8s

rescoreJobLeads (RescoreAll, "Rescore all" on /cv/leads) scores every
matched inbox lead again, for after the profile or the model has
changed. Scores are not wiped first: a lead keeps its old score until
the new one is saved, and the new scored_at column marks which leads the
job has reached, so a job that dies partway leaves no gaps. Leads that
had used up their attempts get them back.

The inbox can also be ordered by when a posting went up, falling back to
when it was found where the source gave no date.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-12 15:52:33 +01:00
co-authored by Claude Opus 5.5
parent 3764ea9c0b
commit 8b902350ad
9 changed files with 261 additions and 32 deletions
+12 -2
View File
@@ -18,7 +18,7 @@ import { gql } from "@/graphql";
// `description` is deliberately not here: it is the full text of the posting
// and is fetched per lead when asked for, as on the tracker.
const LEAD_FIELDS = `id createdAt sourceKind jobTitle company location url postedAt lastSeenAt matched state score scoreReasons jobAppId`;
const LEAD_FIELDS = `id createdAt sourceKind jobTitle company location url postedAt lastSeenAt matched state score scoreReasons scoredAt jobAppId`;
export const useJobLeadsStore = defineStore("jobLeads", () => {
const leads = ref([]);
@@ -107,5 +107,15 @@ export const useJobLeadsStore = defineStore("jobLeads", () => {
return data.scoreJobLeads;
}
return { leads, loading, error, status, fetch, dismiss, restore, promote, fetchDescription, fetchStatus, runSync, scoreAll };
/**
* Score every inbox lead again, scored or not — for after the profile or
* the model has changed. Same contract as runSync(). Each lead keeps its old
* score until its new one lands, so the list never goes blank.
*/
async function rescoreAll() {
const data = await gql(`mutation RescoreJobLeads { rescoreJobLeads }`);
return data.rescoreJobLeads;
}
return { leads, loading, error, status, fetch, dismiss, restore, promote, fetchDescription, fetchStatus, runSync, scoreAll, rescoreAll };
});
+57 -8
View File
@@ -12,11 +12,12 @@
* This view owns the page frame, the single error banner, the run button and
* the list. Data access is in stores/jobLeads.js; nothing here calls gql().
*
* There are two server jobs. "Check now" polls the sources and scores up to
* There are three server jobs. "Check now" polls the sources and scores up to
* forty new leads; "Score unscored" polls nothing and scores the whole
* backlog. Either takes from seconds to many minutes, so the button does not
* wait: the server starts the job and this page polls its status, then
* reloads the list when it finishes.
* backlog; "Rescore all" scores every inbox lead again, for after the profile
* or the model has changed. Each takes from seconds to many minutes, so the
* button does not wait: the server starts the job and this page polls its
* status, then reloads the list when it finishes.
*/
import { ref, computed, onMounted, onBeforeUnmount } from "vue";
import { RouterLink } from "vue-router";
@@ -48,6 +49,9 @@ const search = ref("");
// rejected (not loaded at all until asked for — that is most of every board).
const showLowScores = ref(false);
const showUnmatched = ref(false);
// "score" is the order the server sends; "posted" re-sorts here by the
// posting's own date.
const sortBy = ref("score");
const busyId = ref(null);
const sourcesBox = ref(null);
@@ -88,16 +92,22 @@ const hiddenLow = computed(() =>
tab.value === "new" && !showLowScores.value ? inTab.value.filter(isLow).length : 0,
);
/** When the posting went up; when we first saw it if the source gave no date. */
const postedTime = (lead) => new Date(lead.postedAt ?? lead.createdAt).getTime();
// The server already sorts best-first, unscored after scored, newest first
// within a score, so this only filters.
// within a score, so by score this only filters. By date it re-sorts a copy;
// Array.sort is stable, so postings of the same day stay best-first.
const visibleLeads = computed(() => {
const needle = search.value.trim().toLowerCase();
return inTab.value.filter((lead) => {
const shown = inTab.value.filter((lead) => {
if (tab.value === "new" && !showLowScores.value && isLow(lead)) return false;
if (!needle) return true;
return [lead.jobTitle, lead.company, lead.location, lead.scoreReasons]
.some((field) => field?.toLowerCase().includes(needle));
});
if (sortBy.value === "posted") shown.sort((a, b) => postedTime(b) - postedTime(a));
return shown;
});
function scoreClass(lead) {
@@ -107,6 +117,15 @@ function scoreClass(lead) {
return "jl-score-low";
}
/** The tooltip says when, which during a rescore is how to tell new from old. */
function scoreTitle(lead) {
if (lead.score == null) return "Not scored";
const when = lead.scoredAt
? `, scored ${new Date(lead.scoredAt).toLocaleString(undefined, { dateStyle: "medium", timeStyle: "short" })}`
: "";
return `Fit score ${lead.score} out of 100${when}`;
}
function ageLabel(lead) {
const at = lead.postedAt ?? lead.createdAt;
if (!at) return "";
@@ -172,7 +191,7 @@ async function pollStatus() {
await Promise.all([fetchLeads(), sourcesBox.value?.refresh()]);
}
/** Start one of the two server jobs ("runSync" or "scoreAll") and wait on it. */
/** Start one of the server jobs ("runSync", "scoreAll", "rescoreAll") and wait on it. */
async function start(job) {
try {
// false means a job was already going (the scheduler's, say); either way
@@ -187,6 +206,19 @@ async function start(job) {
}
}
// Matched inbox leads that have a score: what "Rescore all" would redo, on
// top of the unscored ones.
const scoredCount = computed(
() => leads.value.filter((lead) => lead.state === "new" && lead.matched && lead.score != null).length,
);
function rescore() {
const total = scoredCount.value + unscoredCount.value;
// One Claude call per lead, and it replaces scores that were paid for.
if (!confirm(`Score all ${total} inbox leads again? This makes one Claude call per lead.`)) return;
start("rescoreAll");
}
// Matched inbox leads with no score: what "Score unscored" would work
// through. A lead Claude failed on three times stays in this count, though
// the server will not try it again.
@@ -223,6 +255,15 @@ onBeforeUnmount(stopPolling);
</div>
<div class="jl-header-right">
<span class="jl-hint">{{ lastRun }}</span>
<button
v-if="scoredCount"
class="cv-btn"
:disabled="running"
title="Score every inbox lead again, including ones already scored. Use after changing the profile or the model. Old scores stay until replaced."
@click="rescore"
>
Rescore all
</button>
<button
v-if="unscoredCount"
class="cv-btn"
@@ -266,6 +307,10 @@ onBeforeUnmount(stopPolling);
<div class="jl-filterbar">
<input v-model="search" class="ja-input" type="search" placeholder="Search title, company, location, reasons…" />
<select v-model="sortBy" class="ja-input ja-select jl-sort" title="Order of the list">
<option value="score">Best score first</option>
<option value="posted">Newest posting first</option>
</select>
<label v-if="tab === 'new'" class="jl-check">
<input v-model="showLowScores" type="checkbox" />
Below {{ minScore }}<template v-if="hiddenLow"> ({{ hiddenLow }} hidden)</template>
@@ -282,7 +327,7 @@ onBeforeUnmount(stopPolling);
class="jl-lead"
:class="{ 'jl-lead-unmatched': !lead.matched && lead.state === 'new' }"
>
<div class="jl-score" :class="scoreClass(lead)" :title="lead.score == null ? 'Not scored' : `Fit score ${lead.score} out of 100`">
<div class="jl-score" :class="scoreClass(lead)" :title="scoreTitle(lead)">
{{ lead.score ?? "–" }}
</div>
<div class="jl-lead-body">
@@ -468,6 +513,10 @@ onBeforeUnmount(stopPolling);
margin-bottom: 0.75rem;
}
.jl-sort {
flex: 0 0 auto;
}
.jl-check {
display: flex;
align-items: center;