Add a job leads inbox that finds and scores postings
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]>
This commit is contained in:
+41
-5
@@ -15,16 +15,18 @@ Endpoints
|
||||
POST /hotels/scan/stream cheapest-night-in-a-range scan, NDJSON
|
||||
POST /internal/rowing/read read a rowing display photo with Claude
|
||||
POST /internal/jobs/extract read a job posting's page text with Claude
|
||||
POST /internal/jobs/score score a job posting against a profile with
|
||||
Claude
|
||||
POST /internal/email/classify classify an email for the job tracker with
|
||||
Claude
|
||||
(all three: Go backend only - not reachable
|
||||
(all four: Go backend only - not reachable
|
||||
through nginx)
|
||||
|
||||
All the hotel work lives in `travelodge`; this module is the HTTP skin around
|
||||
it - request validation, a response cache, the one-search-at-a-time guard, and
|
||||
the NDJSON framing. The rowing reader (`rowing`), the job posting reader
|
||||
(`jobs`) and the email classifier (`email_classify`) are the routes here that
|
||||
are not public: see the "Internal" sections at the bottom, which open with the
|
||||
(`jobs`), the job lead scorer (`job_score`) and the email classifier
|
||||
(`email_classify`) are the routes here that are not public: see the "Internal" sections at the bottom, which open with the
|
||||
wrapper they are all registered through. The hotel routes are consumed by
|
||||
vue/src/views/hotels/ (SingleStayPanel.vue,
|
||||
CheapestNightPanel.vue, useHotelForm.js), which fetch these paths with the /py
|
||||
@@ -42,11 +44,11 @@ from fastapi import Depends, FastAPI, HTTPException, Request
|
||||
from fastapi.responses import JSONResponse, StreamingResponse
|
||||
from pydantic import BaseModel, Field, field_validator, model_validator
|
||||
|
||||
from . import claude, email_classify, jobs, rowing, travelodge
|
||||
from . import claude, email_classify, job_score, jobs, rowing, travelodge
|
||||
|
||||
app = FastAPI(
|
||||
title="Python API",
|
||||
version="0.5.0",
|
||||
version="0.6.0",
|
||||
docs_url="/docs",
|
||||
openapi_url="/openapi.json",
|
||||
)
|
||||
@@ -787,6 +789,40 @@ def jobs_extract(req: JobExtractRequest) -> jobs.JobPosting:
|
||||
return jobs.extract_posting(req.url, req.title, req.text)
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Internal: job lead scorer
|
||||
# --------------------------------------------------------------------------- #
|
||||
class JobScoreRequest(BaseModel):
|
||||
"""A posting and the profile to judge it against, as the Go backend sends them."""
|
||||
|
||||
profile: str = Field(..., min_length=1, max_length=job_score.MAX_PROFILE_CHARS, description="What the person has done and wants")
|
||||
jobTitle: str = Field(..., min_length=1, max_length=500, description="The role advertised")
|
||||
company: str = Field("", max_length=500, description="The company hiring")
|
||||
location: str = Field("", max_length=500, description="Where the job is based")
|
||||
description: str = Field("", max_length=job_score.MAX_DESCRIPTION_CHARS, description="The posting's text; may be a snippet or empty")
|
||||
|
||||
|
||||
@_internal_claude_route(
|
||||
"/internal/jobs/score",
|
||||
response_model=job_score.LeadScore,
|
||||
summary="Score a job posting against a profile",
|
||||
description=(
|
||||
"Internal to the Go backend's job-lead pipeline; not reachable through nginx. Sends one posting "
|
||||
"and the profile to Claude and returns a 0-100 fit score with a sentence of reasons. A reply "
|
||||
"without a usable score is a 502, not a score of zero."
|
||||
),
|
||||
)
|
||||
def jobs_score(req: JobScoreRequest) -> job_score.LeadScore:
|
||||
"""Score one lead.
|
||||
|
||||
A plain `def` for the same reason as `rowing_read`, and the same error
|
||||
responses. The Go pipeline counts a 502 as a failed attempt at that lead
|
||||
and retries it on a later run; any other failure stops its scoring for the
|
||||
run.
|
||||
"""
|
||||
return job_score.score_posting(req.profile, req.jobTitle, req.company, req.location, req.description)
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Internal: email classifier
|
||||
# --------------------------------------------------------------------------- #
|
||||
|
||||
Reference in New Issue
Block a user