The tracker recorded applications but could not find jobs. A new pipeline (services/job_leads.go, job_sources.go) polls a watch list of sources on a timer or on request, files unseen postings as leads, marks which pass a keyword and location pre-filter, and has Claude score those against a single search profile through a fourth internal Python route, /internal/jobs/score. Sources are Greenhouse, Lever and Ashby company boards (public JSON) and Adzuna and Reed keyword searches (API keys). The two search fetchers are written from the providers' documentation and tested only against stubs. Leads are their own table, not a job status, and are not soft deleted: the (source_kind, external_id) index is the dedup, so a dismissed lead has to remain a row. A lead reaches the tracker only by promotion, which goes through UpsertJobApplication. That upsert moves from the capture handler into services so promotion and the fetcher can share it; the capture endpoint's behaviour is unchanged. /cv/leads is the page: inbox, watch list and profile form. The timer is off unless JOB_LEADS_ENABLED=true and never runs at start-up, so a deploy spends no Claude calls. Co-Authored-By: Claude Opus 5.5 <[email protected]>
32 lines
983 B
Go
32 lines
983 B
Go
package graph
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"adam-french.co.uk/backend/models"
|
|
)
|
|
|
|
// setLeadState moves a lead from one state to another and returns it. It
|
|
// lives here, not in job_lead.resolvers.go, because gqlgen moves anything in
|
|
// a resolvers file that is not a resolver to the bottom on regeneration.
|
|
//
|
|
// The move is refused unless the lead is in `from`, which is what stops a
|
|
// promoted lead being dismissed or restored: its application exists, and
|
|
// flipping the lead would only make the inbox disagree with the tracker.
|
|
func (r *mutationResolver) setLeadState(id int, from, to string) (*models.JobLead, error) {
|
|
var lead models.JobLead
|
|
if err := r.Store.DB.First(&lead, id).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
if lead.State == to {
|
|
return &lead, nil
|
|
}
|
|
if lead.State != from {
|
|
return nil, fmt.Errorf("a %s lead cannot be made %s", lead.State, to)
|
|
}
|
|
if err := r.Store.DB.Model(&lead).Update("state", to).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
return &lead, nil
|
|
}
|