Remove the email pipeline
The mailbox sync (Microsoft Graph and IMAP), its Claude classifier, the /email routes and the Settings page's email section are taken out while the pipeline is unused. The last commit with it is tagged email-pipeline-last; reverting this commit brings it back. The status rules the capture path shares (statusOrder, StatusAdvances, NormalizeStatus) move to job_status.go with their tests. ProcessedEmail stays in the migration, marked dormant, so its history survives for a restored pipeline. golang.org/x/oauth2 is no longer needed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -7,24 +7,80 @@ import (
|
||||
"github.com/99designs/gqlgen/graphql"
|
||||
)
|
||||
|
||||
// The job-status vocabulary, as GraphQL sees it.
|
||||
// The job-status vocabulary: its ranking, the forward-only rule, and how
|
||||
// GraphQL sees it.
|
||||
//
|
||||
// The schema declares `enum JobStatus` (graph/schema/job_application.graphql)
|
||||
// and gqlgen.yml binds it to the two functions below instead of letting
|
||||
// gqlgen generate a Go enum type. That keeps models.JobApplication.Status a
|
||||
// plain string column — no migration, and the email pipeline and the capture
|
||||
// endpoint go on writing strings — while the GraphQL boundary still refuses a
|
||||
// status nobody ranked.
|
||||
// and gqlgen.yml binds it to MarshalJobStatus and UnmarshalJobStatus instead
|
||||
// of letting gqlgen generate a Go enum type. That keeps
|
||||
// models.JobApplication.Status a plain string column — no migration, and the
|
||||
// capture endpoint goes on writing strings — while the GraphQL boundary still
|
||||
// refuses a status nobody ranked.
|
||||
//
|
||||
// statusOrder (email_sync.go) is the vocabulary; the enum in the schema has to
|
||||
// list the same values, and TestJobStatusEnumMatchesStatusOrder fails when
|
||||
// they differ. The functions live in this package, rather than in graph,
|
||||
// because this is where statusOrder is and graph already imports services.
|
||||
// statusOrder is the vocabulary; the enum in the schema has to list the same
|
||||
// values, and TestJobStatusEnumMatchesStatusOrder fails when they differ. The
|
||||
// functions live in this package, rather than in graph, because the capture
|
||||
// path needs them too and graph already imports services.
|
||||
|
||||
// statusOrder ranks the application lifecycle so an update can only move an
|
||||
// application forwards (see StatusAdvances). A status missing from this map is
|
||||
// treated as unknown and never applied. Note that "rejected" and "withdrawn"
|
||||
// sit at the top, so once an application reaches them nothing can move it
|
||||
// back.
|
||||
//
|
||||
// "saved" marks a posting captured from the browser, or promoted from the
|
||||
// leads inbox, but not applied to yet. It ranks lowest so that capturing the
|
||||
// posting again as "applied" advances the row.
|
||||
//
|
||||
// This map is the vocabulary. It is written down in three other places, which
|
||||
// must list the same statuses: `enum JobStatus` in
|
||||
// graph/schema/job_application.graphql (enforced —
|
||||
// TestJobStatusEnumMatchesStatusOrder fails on any difference), the tracker
|
||||
// page (web/src/views/jobStatus.js) and the capture userscript
|
||||
// (STATUS_LABELS in web/public/job-capture.user.js).
|
||||
var statusOrder = map[string]int{
|
||||
"saved": 0,
|
||||
"applied": 1,
|
||||
"screening": 2,
|
||||
"assessment": 3,
|
||||
"interviewing": 4,
|
||||
"offer": 5,
|
||||
"rejected": 6,
|
||||
"withdrawn": 7,
|
||||
}
|
||||
|
||||
// StatusAdvances reports whether next is a forward move from current through
|
||||
// statusOrder. It is what stops a repeat capture of a posting marked "saved"
|
||||
// dragging an interviewing application backwards. An unknown next status is
|
||||
// never applied; an unknown current status is treated as "anywhere before the
|
||||
// start", so any recognised status can take over from it.
|
||||
func StatusAdvances(current, next string) bool {
|
||||
nextOrder, nextExists := statusOrder[next]
|
||||
currentOrder, currentExists := statusOrder[current]
|
||||
return nextExists && (!currentExists || nextOrder > currentOrder)
|
||||
}
|
||||
|
||||
// NormalizeStatus coerces a status that arrives outside GraphQL — the capture
|
||||
// endpoint's body — into the tracked vocabulary, trimming and lowering it and
|
||||
// rejecting anything outside statusOrder. An unrecognised status stored
|
||||
// verbatim would disable the forward-only guard for that row (StatusAdvances
|
||||
// allows any recognised status over an unknown one), so the safe fallback is
|
||||
// "applied".
|
||||
//
|
||||
// The GraphQL mutations do not use it — their status is a JobStatus, which
|
||||
// UnmarshalJobStatus refuses outright when it is not in the vocabulary rather
|
||||
// than quietly storing "applied".
|
||||
func NormalizeStatus(s string) string {
|
||||
lowered := strings.ToLower(strings.TrimSpace(s))
|
||||
if _, ok := statusOrder[lowered]; ok {
|
||||
return lowered
|
||||
}
|
||||
return "applied"
|
||||
}
|
||||
|
||||
// KnownStatus reports whether s is exactly one of the tracked statuses. No
|
||||
// trimming or case folding: see NormalizeStatus for the forgiving version the
|
||||
// email pipeline and the capture endpoint use on values that did not come
|
||||
// through GraphQL.
|
||||
// capture endpoint uses on values that did not come through GraphQL.
|
||||
func KnownStatus(s string) bool {
|
||||
_, ok := statusOrder[s]
|
||||
return ok
|
||||
|
||||
Reference in New Issue
Block a user