From 99fe175ebfbafc11713fda009eb9609714a6cf24 Mon Sep 17 00:00:00 2001 From: Adam French Date: Wed, 14 Oct 2026 17:35:18 +0100 Subject: [PATCH] Delete the old job code now that the tracker runs on its own The job tracker has run from its own image at /jobs/ since 931b02c, so its old copy here goes: the GraphQL schema, resolvers and models for applications, references, sources, leads and the search profile; the capture and email handlers and services; the Python posting reader, lead scorer and email classifier; the Vue pages, stores and the capture-token card on the Environment tab; and the userscript (nginx already redirects its old URL to /jobs/). The six old tables stay in the stp database: AutoMigrate never drops anything, and dropping them is a manual step. The env variables stay in the registry, where they already belong to the jobs service. Docs (CLAUDE.md, DEPLOYMENT.md and the three READMEs) now describe the site without the tracker, and DEPLOYMENT.md lists the jobs service and ./jobs-data. Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 19 +- DEPLOYMENT.md | 13 +- backend/README.md | 240 +- backend/gqlgen.yml | 31 - backend/graph/directives_test.go | 52 +- backend/graph/doc.go | 6 +- backend/graph/generated.go | 5090 +---------------- backend/graph/job_app_reference.resolvers.go | 78 - backend/graph/job_application.resolvers.go | 140 - backend/graph/job_lead.resolvers.go | 220 - backend/graph/job_lead_helpers.go | 31 - backend/graph/model/models_gen.go | 68 - .../graph/schema/job_app_reference.graphql | 38 - backend/graph/schema/job_application.graphql | 82 - backend/graph/schema/job_lead.graphql | 145 - backend/handlers/handle_email_sync.go | 61 - backend/handlers/handle_job_capture.go | 251 - backend/handlers/handle_job_capture_test.go | 264 - backend/handlers/store.go | 14 +- backend/main.go | 81 +- backend/models/models.go | 179 - backend/services/capture_token.go | 133 - backend/services/capture_token_test.go | 126 - backend/services/database.go | 6 - backend/services/email_classify_test.go | 185 - backend/services/email_imap.go | 420 -- backend/services/email_status_test.go | 97 - backend/services/email_sync.go | 994 ---- backend/services/email_sync_test.go | 210 - backend/services/job_leads.go | 827 --- backend/services/job_leads_test.go | 243 - backend/services/job_sources.go | 502 -- backend/services/job_sources_test.go | 281 - backend/services/job_status.go | 75 - backend/services/job_status_test.go | 126 - backend/services/job_upsert.go | 241 - backend/services/job_upsert_test.go | 121 - backend/services/python_call.go | 10 +- backend/services/seed.go | 31 - docker-compose.yml | 6 +- python/README.md | 113 +- python/app/claude.py | 9 +- python/app/email_classify.py | 114 - python/app/job_score.py | 117 - python/app/jobs.py | 114 - python/app/main.py | 118 +- python/tests/test_claude.py | 4 +- python/tests/test_email_classify.py | 245 - python/tests/test_job_score.py | 175 - python/tests/test_jobs.py | 160 - vue/README.md | 73 +- vue/public/job-capture.user.js | 479 -- vue/src/layouts/CVLayout.vue | 2 +- vue/src/stores/createCrudStore.js | 5 +- vue/src/stores/jobAppReferences.js | 21 - vue/src/stores/jobApplications.js | 39 - vue/src/stores/jobLeads.js | 121 - vue/src/stores/jobSearchProfile.js | 44 - vue/src/stores/jobSources.js | 24 - vue/src/stores/places.js | 2 +- vue/src/views/CV/JobApplicationForm.vue | 129 - vue/src/views/CV/JobApplications.vue | 841 --- vue/src/views/CV/JobLeads.vue | 660 --- vue/src/views/CV/JobReferences.vue | 250 - vue/src/views/CV/JobSearchProfile.vue | 167 - vue/src/views/CV/JobSources.vue | 198 - vue/src/views/CV/jobStatus.js | 31 - vue/src/views/CV/jobs-shared.css | 39 - vue/src/views/admin/CaptureToken.vue | 127 - vue/src/views/admin/Diagnostics.vue | 4 +- vue/src/views/admin/Environment.vue | 3 - vue/src/views/admin/env.css | 4 +- 72 files changed, 123 insertions(+), 16046 deletions(-) delete mode 100644 backend/graph/job_app_reference.resolvers.go delete mode 100644 backend/graph/job_application.resolvers.go delete mode 100644 backend/graph/job_lead.resolvers.go delete mode 100644 backend/graph/job_lead_helpers.go delete mode 100644 backend/graph/schema/job_app_reference.graphql delete mode 100644 backend/graph/schema/job_application.graphql delete mode 100644 backend/graph/schema/job_lead.graphql delete mode 100644 backend/handlers/handle_email_sync.go delete mode 100644 backend/handlers/handle_job_capture.go delete mode 100644 backend/handlers/handle_job_capture_test.go delete mode 100644 backend/services/capture_token.go delete mode 100644 backend/services/capture_token_test.go delete mode 100644 backend/services/email_classify_test.go delete mode 100644 backend/services/email_imap.go delete mode 100644 backend/services/email_status_test.go delete mode 100644 backend/services/email_sync.go delete mode 100644 backend/services/email_sync_test.go delete mode 100644 backend/services/job_leads.go delete mode 100644 backend/services/job_leads_test.go delete mode 100644 backend/services/job_sources.go delete mode 100644 backend/services/job_sources_test.go delete mode 100644 backend/services/job_status.go delete mode 100644 backend/services/job_status_test.go delete mode 100644 backend/services/job_upsert.go delete mode 100644 backend/services/job_upsert_test.go delete mode 100644 python/app/email_classify.py delete mode 100644 python/app/job_score.py delete mode 100644 python/app/jobs.py delete mode 100644 python/tests/test_email_classify.py delete mode 100644 python/tests/test_job_score.py delete mode 100644 python/tests/test_jobs.py delete mode 100644 vue/public/job-capture.user.js delete mode 100644 vue/src/stores/jobAppReferences.js delete mode 100644 vue/src/stores/jobApplications.js delete mode 100644 vue/src/stores/jobLeads.js delete mode 100644 vue/src/stores/jobSearchProfile.js delete mode 100644 vue/src/stores/jobSources.js delete mode 100644 vue/src/views/CV/JobApplicationForm.vue delete mode 100644 vue/src/views/CV/JobApplications.vue delete mode 100644 vue/src/views/CV/JobLeads.vue delete mode 100644 vue/src/views/CV/JobReferences.vue delete mode 100644 vue/src/views/CV/JobSearchProfile.vue delete mode 100644 vue/src/views/CV/JobSources.vue delete mode 100644 vue/src/views/CV/jobStatus.js delete mode 100644 vue/src/views/CV/jobs-shared.css delete mode 100644 vue/src/views/admin/CaptureToken.vue diff --git a/CLAUDE.md b/CLAUDE.md index 6588987..8b98b7c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -58,30 +58,30 @@ Dockerized multi-service personal website self-hosted on a Raspberry Pi. **Frontend** (`vue/`): Vue 3 SPA with Vite, Tailwind CSS v4, Pinia stores, Vue Router. Built in a separate container; assets served through Nginx (production) or proxied to Vite dev server (dev mode). -**Python API** (`python/`): FastAPI app served by uvicorn on port 8000. Nginx proxies `/py/` to it and strips the prefix, so routes in `python/app/main.py` are written relative to `/`. Swagger UI at `/py/docs`. Dev mode mounts `python/app` and runs uvicorn with `--reload`. **Every Claude call in the stack lives here**, behind four internal routes: `/internal/rowing/read` (behind `POST /api/rowing`), `/internal/jobs/extract` (behind `POST /api/jobs/capture/extract`), `/internal/jobs/score` (behind the job-lead pipeline) and `/internal/email/classify` (behind the email sync). The Go backend calls them directly over the Docker network through `services.CallPython`, and nginx 404s `/py/internal/`. The model is one setting for all four, `CLAUDE_MODEL` (default `claude-sonnet-5-5`), chosen on the admin panel's Environment tab; `python/app/claude.py` shapes the request per model. Adding another route is a short recipe in `python/README.md` ("Internal routes"). +**Python API** (`python/`): FastAPI app served by uvicorn on port 8000. Nginx proxies `/py/` to it and strips the prefix, so routes in `python/app/main.py` are written relative to `/`. Swagger UI at `/py/docs`. Dev mode mounts `python/app` and runs uvicorn with `--reload`. **The site's Claude call lives here**, behind an internal route: `/internal/rowing/read` (behind `POST /api/rowing`). The Go backend calls it directly over the Docker network through `services.CallPython`, and nginx 404s `/py/internal/`. The model is one setting, shared with the job tracker, `CLAUDE_MODEL` (default `claude-sonnet-5-5`), chosen on the admin panel's Environment tab; `python/app/claude.py` shapes the request per model. Adding another route is a short recipe in `python/README.md` ("Internal routes"). -**Job tracker** (`jobs` service, `/jobs/`): the job application tracker, leads inbox, email pipeline and capture userscript now live in their own repo (`adamf/job-tracker` on Gitea) and run here as a published image, with their own Postgres database and role. It has no login: it asks the backend's `/auth/validate-admin` with the visitor's cookies. **Transitional:** the old job code is still in `backend/`, `python/` and `vue/` but unused (the backend no longer starts its schedulers or serves the capture and email routes, and `/cv/jobs` and `/cv/leads` redirect). Delete it once the tracker has run for a while; until then, sections below that describe job features in this repo are out of date. +**Job tracker** (`jobs` service, `/jobs/`): the job application tracker, leads inbox, email pipeline and capture userscript now live in their own repo (`adamf/job-tracker` on Gitea) and run here as a published image, with their own Postgres database and role. It has no login: it asks the backend's `/auth/validate-admin` with the visitor's cookies. Nothing of it is left in `backend/`, `python/` or `vue/`; nginx redirects the old `/cv/jobs`, `/cv/leads` and userscript URLs to `/jobs/`. A push to that repo's `main` publishes the image and rolls this stack's `jobs` container onto it; pin `JOBS_IMAGE_TAG` in `.env` to hold a version. Its variables are in `env_registry.json` with `services: ["jobs"]`. **Nginx** (`nginx/`): Reverse proxy + SPA server. Config is templated (`nginx.conf.template`) and selected at runtime by `entrypoint.sh` based on `DEV_MODE` and certificate presence. Rate limiting on login (5/min), API (30/sec), uploads (5/min). Proxied routes are written once, in `nginx/nginx_routes.conf.template`, which both the production and dev configs include — add a new route there. Production-only pieces (TLS, static asset caching, the GraphQL rate-limit zone, security headers) stay in `nginx.conf.template`; a new rate-limit zone must be declared in both `http` blocks. ## Backend Structure - `main.go` — entry point: wires up DB, services, router -- `handlers/store.go` — `Store` struct holds DB, SpotifyAuth, Auth, EmailSync, etc. Passed to all handlers +- `handlers/store.go` — `Store` struct holds DB, SpotifyAuth, Auth, Notes, etc. Passed to all handlers - `handlers/handle_*.go` — REST handlers grouped by domain - `graph/schema/*.graphql` — GraphQL schema files (source of truth) - `graph/*.resolvers.go` — resolver implementations (one per schema file, `follow-schema` layout) - `graph/generated.go` — auto-generated by gqlgen, do not edit - `graph/model/models_gen.go` — auto-generated GraphQL models, do not edit -- `models/models.go` — GORM database models (User, Post, Message, Activity, Favorite, Rowing, JobApplication, JobSource, JobLead, …) +- `models/models.go` — GORM database models (User, Post, Message, Activity, Favorite, Rowing, Bookmark, Place) - `graph/directives.go` — the `@admin` / `@signedIn` schema directives (see Key Patterns) -- `services/` — database init, JWT auth, WebSocket server, Spotify OAuth, Gitea feed, the Python-service call helper (`python_call.go`), job status vocabulary (`job_status.go`), the job-lead pipeline (`job_leads.go`, `job_sources.go`), the tracker upsert (`job_upsert.go`), DB seeding. There is no Claude client in Go any more +- `services/` — database init, JWT auth, WebSocket server, Spotify OAuth, Gitea feed, the Python-service call helper (`python_call.go`), the `.env` registry (`env_manager.go`), DB seeding. There is no Claude client in Go any more ## Frontend Structure - `src/graphql.js` — thin axios-based GraphQL client (`POST /api/graphql`) - `src/api.js` — thin REST client for the `/api` JSON endpoints; failures become an `ApiError` carrying the backend's `error` message and the status -- `src/stores/` — Pinia stores for auth, posts, favorites, activities, songs, messages, homeData, places, jobApplications, jobAppReferences, jobSources, jobLeads, jobSearchProfile. `createCrudStore.js` is the factory behind places, jobApplications, jobAppReferences and jobSources; `createMirrorStore.js` is the one behind the home-page slices +- `src/stores/` — Pinia stores for auth, posts, favorites, activities, songs, messages, homeData, places. `createCrudStore.js` is the factory behind places; `createMirrorStore.js` is the one behind the home-page slices - `src/views/` — page components (Home, Admin, CV, Notes, Bookmarks, shrines) - `src/components/` — reusable UI components - `src/assets/styles.css` — design tokens (Tailwind `@theme`), base element styles, shared classes and transitions. `layouts/CVLayout.vue` re-points the colour tokens for the light CV theme. See "Styling" in `vue/README.md`. @@ -92,13 +92,10 @@ Dockerized multi-service personal website self-hosted on a Raspberry Pi. - **Auth flow**: Login sets `access_token` (7 days) and `refresh_token` (365 days) as HTTP-only cookies (`backend/main.go:96`). `AuthMiddleware` validates tokens and injects user into Gin context. `AuthContextMiddleware` passes Gin context into GraphQL resolver context. Revocation is by `User.TokenVersion`: every token carries the version it was minted with, and logout or a password change bumps it, invalidating all of that user's tokens. On the frontend the router guard awaits `auth.ensureLoaded()` (a standalone `me` query), not the home query; `homeData` exposes `settled` (finished either way) as well as `loaded` (succeeded). - **GraphQL auth is declared in the schema.** The `/api/graphql` endpoint has no guarding middleware; `AuthContextMiddleware` only makes the user *available*. A field is protected by annotating it `@admin` or `@signedIn` in `graph/schema/*.graphql` (implemented in `graph/directives.go`). `graph/directives_test.go` fails if a mutation has neither directive and is not on its short public allow-list (`login`, `logout`, `refreshToken`), so a new mutation cannot ship unguarded by accident; a new *query* is public unless you annotate it. Finer rules (post ownership, hiding private messages) stay in the resolver. See `backend/graph/doc.go`. - **Adding a GraphQL entity**: model in `models/models.go` (and the AutoMigrate list), schema file with directives, mapping in `gqlgen.yml`, `make generate`, fill in the resolvers; on the frontend a store built with `createCrudStore`. Model `ID uint` binds directly via `graphql.UintID` — there are no hand-written ID resolvers. Full recipe in `backend/README.md`. -- **Job status is one vocabulary.** `enum JobStatus` in `graph/schema/job_application.graphql` is what GraphQL accepts, and a test ties it to `services.statusOrder`. Three copies are *not* checked and must be edited by hand with it: the classifier prompt in `python/app/email_classify.py`, `vue/src/views/CV/jobStatus.js`, and `STATUS_LABELS` in the userscript. - **Spotify tokens**: Persisted to `/backend/token/spotify_token.json` inside the container, surviving restarts. -- **Job capture**: `vue/public/job-capture.user.js` is a Violentmonkey userscript, served by the site and installed from `/cv/jobs`, that adds the posting open in the browser to the tracker. It calls the three `/api/jobs/capture` REST routes with a bearer token because cookies do not travel from other origins. The token is generated on the admin panel and stored hashed in `backend/token/job_capture_token.json`; there is no env var for it. Bump its `@version` on every edit or installed copies will not update. See "Job capture" in `backend/README.md`. -- **Job leads**: `/cv/leads` is an inbox of postings the backend finds itself. `services/job_leads.go` polls each `JobSource` (Greenhouse, Lever and Ashby boards; Adzuna and Reed searches), files new postings as `JobLead` rows, keyword-filters them and has Claude score the survivors against the single `JobSearchProfile` row. A lead reaches the tracker only by promotion, through `services.UpsertJobApplication` — the same upsert the capture endpoint uses. `JobLead` is not soft deleted: a dismissed lead has to stay a row or the next poll re-adds it. The timer is off unless `JOB_LEADS_ENABLED=true`; "Check now" works either way. See "Job leads" in `backend/README.md`. -- **Environment tab**: `/admin` → Environment edits `.env` on the Pi. The backend never touches the file: it validates the edit and writes `env-apply/run/request.json`; `env-apply/apply.py`, run on the host by a systemd path unit (`env-apply/install.sh`), rewrites `.env` and recreates only the services that read the change. `backend/services/env_registry.json` is the single list of variables — **add new variables there as well as `.env.example`** (a test enforces it); a variable the Python service reads must also be added to the `python` service's explicit `environment:` list in `docker-compose.yml`, which a second test checks against the registry, with `editable: false` for anything that renames a container, moves a port or is only read at first init. Secrets are write-only: no endpoint returns one. See "Environment tab" in `backend/README.md`. +- **Environment tab**: `/admin` → Environment edits `.env` on the Pi. The backend never touches the file: it validates the edit and writes `env-apply/run/request.json`; `env-apply/apply.py`, run on the host by a systemd path unit (`env-apply/install.sh`), rewrites `.env` and recreates only the services that read the change. `backend/services/env_registry.json` is the single list of variables — **add new variables there as well as `.env.example`** (a test enforces it); a variable the Python service or the job tracker reads must also be added to the `python` or `jobs` service's explicit `environment:` list in `docker-compose.yml`, which a second test checks against the registry, with `editable: false` for anything that renames a container, moves a port or is only read at first init. Secrets are write-only: no endpoint returns one. See "Environment tab" in `backend/README.md`. - **Gitea feed**: Backend proxies and caches (1 min TTL) the Gitea activity feed API. -- **All GORM models use soft delete** (`gorm.DeletedAt` field) — except `ProcessedEmail` and `JobLead`, whose dedup must see history, and the single-row `JobSearchProfile`. Note that a `uniqueIndex` still collides with soft-deleted rows. +- **All GORM models use soft delete** (`gorm.DeletedAt` field). Note that a `uniqueIndex` still collides with soft-deleted rows. ## Further documentation diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index 5060456..edec32b 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -56,6 +56,7 @@ backend icecast2 gitea sb sb-pub python | | | silverbullet-public (notes site) | `${SILVERBULLET_PUBLIC_HOST}` | `${SILVERBULLET_PUBLIC_PORT}` | `/notes/` (**public**, read-only) | no | | silverbullet-git | n/a | n/a | none (timer loop) | no | | python (FastAPI) | `${PYTHON_HOST}` | `${PYTHON_PORT}` | `/py/`, docs at `/py/docs` | no | +| jobs (job tracker, published image) | `jobs` | 8080 | `/jobs/` (admin-gated by the app itself) | no | | icecast2 + liquidsoap | `${ICECAST_HOST}` | `${ICECAST_PORT}` | `/radio/` | **harbor port only** | | gitea | `${GITEA_HOST}` | 3000, 2222 | `/gitea/` | **3000, 2222** | | vue | `vue` | 5173 (dev only) | `/` (dev only) | no | @@ -231,7 +232,8 @@ of deleting the directory: |---|---|---| | `./certbot/conf` | TLS certificates and **private keys** | Gitignored. Never commit. | | `./certbot/www` | ACME challenge webroot | Transient by nature | -| `./backend/token/` | **Spotify OAuth refresh token** (`spotify_token.json`) and the **job capture token hash** (`job_capture_token.json`) | Gitignored. Without this mount, Spotify would need re-authorising after every rebuild, and the capture userscript a new token from the admin panel. | +| `./backend/token/` | **Spotify OAuth refresh token** (`spotify_token.json`) | Gitignored. Without this mount, Spotify would need re-authorising after every rebuild. | +| `./jobs-data` | The job tracker's **capture token hash** and Graph OAuth session | Gitignored. Must be owned by uid 1000, the user the `jobs` image runs as. | | `./env-apply/run` | The admin panel's queued `.env` change (`request.json`) and the host's report on it (`status.json`) | Gitignored. Transient, but must be owned by the deploy user, not root — see §5. | | `./gitea/data` | Git repositories, LFS objects, avatars, sessions | The actual git data | | `./gitea/config` | Gitea's live `app.ini` | Gitignored; generated from the template on first boot and then owned by Gitea | @@ -262,10 +264,11 @@ convention for overriding `app.ini` keys), and `python` receives an explicit allow-list, so it never sees the database password or any API key other than the two it uses (`TFL_APP_KEY`, and `CLAUDE_API_KEY`, plus `CLAUDE_MODEL`, which picks the model). The Python service -makes every Claude call in the stack — rowing photo reader, job posting reader, -job lead scorer and email classifier — so it is the only container that reads `CLAUDE_API_KEY`; -the backend receives it through `env_file` but no longer uses it. A new -variable for the Python service has to be added to that allow-list as well as +makes the site's one Claude call (the rowing photo reader); the `jobs` container +(the job tracker, built from its own repo) makes its own, and gets a similar +allow-list with its own database role. The backend receives `CLAUDE_API_KEY` +through `env_file` but does not use it. A new variable for either service has +to be added to its allow-list as well as `.env.example` and `backend/services/env_registry.json`; backend tests fail if the three disagree. diff --git a/backend/README.md b/backend/README.md index 2acfd68..28cb0db 100644 --- a/backend/README.md +++ b/backend/README.md @@ -112,8 +112,7 @@ test can see. and ends. - `createPlace`, `updatePlace`, `deletePlace` and the `places` query — `@signedIn`. Places are a shared list with no per-user ownership. -- `users`, `user`, `jobApplications`, `jobApplication`, `jobAppReferences` — - queries, but `@admin`: private data. +- `users`, `user` — queries, but `@admin`: private data. **What a directive cannot say stays in the resolver**, using `IsAdminFromCtx` / `UserIDFromCtx` from `graph/context.go`: @@ -172,13 +171,12 @@ for the things GraphQL cannot do: | REST endpoint | why it is not GraphQL | | --- | --- | | `/auth/*` | cookie handling and the status-code-only admin probe | -| `/spotify/callback`, `/email/callback` | OAuth providers redirect a *browser* here | +| `/spotify/callback` | OAuth providers redirect a *browser* here | | `/messages/upload`, `/radio/upload`, `/rowing` (POST) | multipart file uploads | | `/notes/*path` | streams a file download, not JSON | | `/ws` | WebSocket upgrade | | `/rowing` (GET), `/spotify/listening`, `/spotify/recent` | predate the equivalent queries; kept working | -| `/admin/env`, `/admin/logs`, `/admin/capture-token` | process environment and files on disk, not the data model | -| `/jobs/capture`, `/jobs/capture/status`, `/jobs/capture/extract` | called by a userscript on other sites' origins, where the `SameSite=Lax` auth cookies are never sent; they take a bearer token instead | +| `/admin/env`, `/admin/logs` | process environment and files on disk, not the data model | ### Environment tab @@ -192,14 +190,14 @@ host, which is the part trusted to act. read it. It is embedded in the binary and read from the checkout by the host script, so one file decides what the panel offers and what the host accepts. A test fails if it and `.env.example` disagree. -- **The `python` service is a third place.** It is the one container given an +- **The `python` and `jobs` services are a third place.** They are given an explicit `environment:` list in `docker-compose.yml` instead of the whole - `.env`, so that it never holds the database password or the JWT secret. A - new Python variable therefore goes in the registry (with `python` in its - `services`), in `.env.example`, *and* in that list. + `.env`, so that they never hold the site's database password or the JWT + secret. A new variable for either therefore goes in the registry (with the + service in its `services`), in `.env.example`, *and* in that list. `TestEnvRegistryMatchesComposePythonEnvironment` reads the compose file and - fails if a variable the registry says python reads is not passed to it, or - if an editable variable passed to it does not list `python`. Locked + fails if a variable the registry says one of them reads is not passed to + it, or if an editable variable passed to it does not list that service. Locked variables carry no `services` and are exempt (`PYTHON_PORT` is one). - `GET /admin/env` — the registry plus state from this process's own environment. A secret's value is never sent, only "set" and, for values of @@ -221,109 +219,11 @@ host, which is the part trusted to act. The backend is always among the recreated services, because the values the panel shows are the ones this process started with. -### Job capture - -`handlers/handle_job_capture.go` is the server half of the browser userscript -(`vue/public/job-capture.user.js`, installed from the tracker page) that adds -the posting open in the browser to the job tracker. - -- **Auth** is `Authorization: Bearer `, checked by - `CaptureTokenMiddleware`. The token opens these three routes and nothing - else — it cannot read the tracker or reach GraphQL. **With no token - generated the routes are off (503)**; that never means "no auth". -- **The token is generated in the admin panel**, not set in `.env` - (`services/capture_token.go`; `GET`/`POST`/`DELETE /admin/capture-token`, - cookie-authenticated like the rest of the admin group). It is 32 random - bytes, shown once; only its SHA-256 is kept, in - `/backend/token/job_capture_token.json` beside the OAuth tokens, so it - survives restarts and rebuilds. There is one token at a time: generating - again replaces it, which is how a leaked one is rotated. -- `GET /jobs/capture/status?url=` — is this posting already tracked, and at - what status. Drives the script's badge. -- `POST /jobs/capture/extract` — page text in, `{jobTitle, company, location, - notes}` out, read by Claude through the Python service - (`/internal/jobs/extract`, see [Calling the Python service](#calling-the-python-service)). - Stores nothing. -- `POST /jobs/capture` — an **upsert**. A posting is matched by its canonical - URL (`services.CanonicalJobURL` strips tracking parameters and folds LinkedIn's - several URL shapes into one), then by `(company, job title)` the way the - email pipeline matches (`services.UpsertJobApplication`, shared with lead - promotion). A repeat capture only ever adds: status moves - forwards, empty fields are filled, nothing is overwritten. - -The upsert is what keeps this and the email pipeline from making two rows for -one application. It is not watertight: the pipeline still matches on the exact -title, so a posting captured as "Senior Engineer" whose confirmation email -says "Senior Engineer (Platform)" becomes a second row. - -### Job leads - -Where the tracker records applications, this finds postings. It is GraphQL -throughout (`graph/schema/job_lead.graphql`, all `@admin`) with the work in -`services/job_leads.go` and `services/job_sources.go`; the page is `/cv/leads`. - -- **Three tables.** `JobSource` is one thing to poll: a company's board on - Greenhouse, Lever or Ashby (public JSON, no key), or a keyword search on - Adzuna or Reed (keys in `.env`). `JobLead` is one posting found. It is - **not soft deleted**, like `ProcessedEmail`: the unique index on - `(source_kind, external_id)` is the dedup, and it only keeps a dismissed - lead dismissed if that lead is still a row. `JobSearchProfile` is a single - row: the profile text, three keyword lists and a minimum score. -- **A run** (`JobLeadService.Run`) is fetch → store → pre-filter → score. - Every enabled source is polled; one failing records its error on the source - and the rest carry on. Postings not seen before become leads; ones already - known only have `last_seen_at` moved. A posting whose canonical URL is - already in the tracker is filed as `promoted`, linked to that application, - so the inbox never offers it. -- **The pre-filter** is keywords on the title and location, no Claude. It - exists because a company board is mostly irrelevant, and it decides which - leads are shown and which cost a call. `matched` is recomputed for every - inbox lead on each run, so editing the keywords applies to old leads too. -- **Scoring** sends each matched, unscored lead and the profile text to the - Python service's `/internal/jobs/score`. At most 40 a run, newest first; a - lead Claude cannot score is retried on three runs and then left. With an - empty profile nothing is scored. If scoring is unavailable (no API key, - Python down) the run stops scoring without spending an attempt on any lead. -- **Scoring the backlog.** The `scoreJobLeads` mutation - (`JobLeadService.ScoreAll`, "Score unscored" on the page) scores every - matched, unscored lead with no cap and without polling any source. It is - for the backlog a first poll of several boards leaves behind, or leads - that arrived before the profile was written. A lead that fails is tried - once per press. It stops after an hour; pressing again continues. -- **Rescoring.** The `rescoreJobLeads` mutation (`RescoreAll`, "Rescore all" - on the page) scores every matched inbox lead again, for after the profile - or `CLAUDE_MODEL` has changed. It does not wipe scores first: a lead keeps - its old score until the new one is saved, and `scored_at` is what marks a - lead as done by this job. A job that fails partway leaves a mix of old and - new scores, and pressing again starts over. -- **When it runs.** `JOB_LEADS_ENABLED=true` starts a timer - (`JOB_LEADS_INTERVAL`, default `6h`); it does not run at start-up, so a - deploy spends nothing. The `runJobLeadSync` mutation starts a run in a - goroutine and returns at once, whether or not the timer is on, and - `jobLeadSyncStatus` reports on it (and on `scoreJobLeads` and - `rescoreJobLeads`; only one of the three jobs runs at a time) — a run can take minutes, so unlike - `POST /email/sync` it does not hold the request open. The status is in - memory and resets on restart. -- **Promotion** (`promoteJobLead`) is the only way a lead reaches the tracker. - It calls `services.UpsertJobApplication` with status `saved`, the lead's - text and a notes line carrying the score — the same upsert as the capture - endpoint, so a posting captured from the browser in the meantime is linked - to, not duplicated. - -The Adzuna and Reed response structs were written from the providers' -documentation, not against live responses (they need keys). If one of those -sources reports a decode error or zero results, compare its struct in -`job_sources.go` with a real reply first. Adzuna only returns a snippet of -each description, so its leads are scored on less text. - -Most of this needs Postgres and has no unit test: what is tested is the -fetchers (against stub servers), the pre-filter, how a fetched posting becomes -a row, and the scoring call. - ## Calling the Python service Every Claude call the site makes lives in the Python service; this backend has -no Anthropic client and does not read `CLAUDE_API_KEY`. It reaches four +no Anthropic client and does not read `CLAUDE_API_KEY`. (The job tracker at +`/jobs/` is a separate app with its own Claude calls.) It reaches the internal routes directly over the Docker network (`http://$PYTHON_HOST:$PYTHON_PORT`, default `python:8000`), never through nginx, which answers 404 for `/py/internal/`: @@ -331,31 +231,27 @@ nginx, which answers 404 for `/py/internal/`: | route | caller | sends | gets back | | --- | --- | --- | --- | | `/internal/rowing/read` | `POST /rowing` (`handlers/handle_rowing.go`) | `{media_type, data}` (image, base64) | `{timeMinutes, timeSeconds, distance}` | -| `/internal/jobs/extract` | `POST /jobs/capture/extract` (`handlers/handle_job_capture.go`) | `{url, title, text}` | `{jobTitle, company, location, notes}` | -| `/internal/jobs/score` | the lead pipeline (`services/job_leads.go`) | `{profile, jobTitle, company, location, description}` | `{score, reasons}` | -| `/internal/email/classify` | the email pipeline (`services/email_sync.go`) | `{message}` | `EmailAnalysis` (below) | - -All four go through one function, `services.CallPython[T]` in +Every route goes through one function, `services.CallPython[T]` in `services/python_call.go`: marshal the body, POST it, decode a 200 into `T`. It has the one HTTP client (two-minute timeout, above the Python side's own worst case of a retried Claude call) and the one rule for failures: - a **502 whose `detail` is a string** is a message the route wrote for a person ("failed to parse image data"). It comes back as a - `*services.PythonError`, and the two HTTP handlers relay it to the browser; + `*services.PythonError`, and the HTTP handler relays it to the browser; - **anything else** — connection refused, a 422 (its `detail` is a list), a 503 for an unset `CLAUDE_API_KEY`, a reply that will not decode — is an ordinary error. Callers log it and show something generic. -It lives in `services` because both `handlers` and `services` need it and -`handlers` already imports `services`. A new internal route needs only a +It lives in `services` so that a background job there could use it as well +as a handler. A new internal route needs only a request struct, a reply struct and a one-line call. ## Services Everything is constructed in `main` from environment variables and handed to -`handlers.Store`. Nothing here fails start-up: a missing Spotify token, an -unconfigured mailbox or an absent Steam key all just leave that feature +`handlers.Store`. Nothing here fails start-up: a missing Spotify token or an +absent Steam key all just leave that feature dormant, which is why callers nil-check `Store.SpotifyClient` and friends. - **database.go** — Postgres via GORM. There are no migration files: @@ -370,75 +266,13 @@ dormant, which is why callers nil-check `Store.SpotifyClient` and friends. - **spotify.go**, **steam.go**, **gitea.go** — third-party reads. Results are cached on `Store` with TTLs of 1 min (Spotify recent, Gitea) and 5 min (Steam). -- **email_sync.go** / **email_imap.go** — the job-application pipeline: fetch - recent mail (Microsoft Graph *or* a hand-rolled IMAP client), keyword-filter - it, have each survivor classified, create or advance a `JobApplication`. - Runs on a timer and can be triggered by an admin. - - The classification is the Python service's `/internal/email/classify`, - which owns the prompt, the Claude call and the parsing of the model's - reply. Go sends one string — `Subject:`, `From:` and `Date:` lines, a blank - line, the cleaned body (capped at 4,000 bytes; the whole message at the - 200,000 characters Python accepts) — and gets back `EmailAnalysis`: - `isJobEmail`, `action`, `company`, `jobTitle`, `status`, and the nullable - `location`, `url`, `appliedAt`, `notes`. Everything either side of that - call is unchanged and still here: the pre-filter, dedup, retry accounting, - matching on (company, job title), and the forward-only status rule. Any - failure of the call, whatever its status code, is a failed attempt at that - email. -- **job_leads.go** / **job_sources.go** — the job-lead pipeline. See - [Job leads](#job-leads). -- **job_upsert.go** — `UpsertJobApplication`, the one way a posting is added - to the tracker without duplicating a row: used by the capture endpoint and - by promoting a lead. - **python_call.go** — `CallPython`, the one way to reach the Python service's internal routes. See [Calling the Python service](#calling-the-python-service). -- **job_status.go** — how the `JobStatus` GraphQL enum is read and written. - See [Job status](#job-status). - **notes.go** — path-traversal-safe file lookup for the notes directory. - **seed.go** — dev-only test data. Creates an admin with the password `password`, so it must never run in production (`SEED_DB=true` is set only in `docker-compose.dev.yml`). -## Job status - -A job application's status is one of eight lowercase strings: `saved`, -`applied`, `screening`, `assessment`, `interviewing`, `offer`, `rejected`, -`withdrawn`. The list is `statusOrder` in `services/email_sync.go`, which also -ranks them — the email pipeline and the capture endpoint only ever move a row -forwards through it (`services.StatusAdvances`). - -GraphQL knows the same list as `enum JobStatus` -(`graph/schema/job_application.graphql`), used for `JobApplication.status` and -both inputs. `TestJobStatusEnumMatchesStatusOrder` in -`services/job_status_test.go` parses the schema file and fails unless the enum -and the map hold the same statuses in the same order, so adding a status means -editing both. (The classifier prompt in the Python service, the tracker page -and the userscript list them too, and nothing checks those.) - -The enum is bound in `gqlgen.yml` to `services.MarshalJobStatus` / -`UnmarshalJobStatus` instead of a generated Go type, for two reasons: - -- **The column stays a `string`.** `models.JobApplication.Status` binds as it - is; there is no migration and no conversion in the pipeline. -- **Input is strict, output is lenient.** A mutation with a status outside the - list is refused (`"hired" is not a valid JobStatus`) — nothing is coerced to - `applied` any more. But a row already holding something else, such as the - Title Case values the tracker once wrote, must not break reads: `status` is - non-null, so a serialisation error on one row would null the entire - `jobApplications` list. On the way out a value that matches once trimmed and - lowercased is sent in its canonical form, and anything else is sent exactly - as stored for the tracker to display and correct. - -On the wire nothing changed from when the field was a `String`: the client -sends `"applied"` as a JSON string variable and reads back `"applied"`. (An -enum does differ for a status written *inline* in a query document, which must -now be `status: applied`, unquoted. The front end only uses variables.) - -`services.NormalizeStatus`, which trims, lowercases and falls back to -`applied`, is still what the email pipeline and `POST /jobs/capture` use on -values that do not come through GraphQL. - ## Regenerating gqlgen The `.graphql` files are the source of truth. @@ -461,9 +295,8 @@ the end of it — which is why shared helpers live in `*_helpers.go` instead. to the schema without a corresponding entry in `gqlgen.yml` gets you a fresh generated struct rather than the model you expected. -Two scalar-level bindings in `gqlgen.yml` are worth knowing about: `ID` lists -both `graphql.IntID` and `graphql.UintID` (see IDs under Gotchas), and -`JobStatus` points at the hand-written marshaller described above. +One scalar-level binding in `gqlgen.yml` is worth knowing about: `ID` lists +both `graphql.IntID` and `graphql.UintID` (see IDs under Gotchas). If you delete a field or stop needing a resolver, delete the resolver function by hand before regenerating; otherwise gqlgen keeps it, commented out, in a @@ -471,8 +304,7 @@ warning block at the end of the file. ## Gotchas -- **Soft delete everywhere.** Every model except `ProcessedEmail` has a - `gorm.DeletedAt`, so `Delete` sets a timestamp and later queries filter the +- **Soft delete everywhere.** Every model has a `gorm.DeletedAt`, so `Delete` sets a timestamp and later queries filter the row out. Rows are never actually removed, and a `uniqueIndex` still collides with deleted rows — a soft-deleted username cannot be reused. - **`Preload` is not lazy.** `Post.Author` is nil unless the query preloads it; @@ -486,9 +318,7 @@ warning block at the end of the file. unsigned fields are not IDs and still have resolvers: `Message.authorId`, `Rowing.time`, `Rowing.distance`. - **Deletes error on a missing id.** Every delete mutation loads the row - first. `deleteJobApplication` and `deleteJobAppReference` return `Boolean!` - rather than the row, so the only value they ever return is `true`; a wrong - id is a `record not found` error, not `false`. + first, so a wrong id is a `record not found` error. - **`Message.AuthorID` is not a user id.** It is a per-process counter handed out by the chat hub on connect, meaningless across restarts. - **The chat table is capped.** Every insert soft-deletes all but the newest @@ -500,19 +330,6 @@ warning block at the end of the file. stripping and the JSON parsing are all in the Python service; this side receives typed JSON or an error (see [Calling the Python service](#calling-the-python-service)). -- **The email pipeline retries a failure up to `maxEmailAttempts` (3) times.** - A failed email is recorded with action `"error"` and an attempt counter; - while it has attempts left the next sync reprocesses it and updates the same - row. Because the fetch window is anchored to *processing* time, which has - already moved past the failure, the sync also rewinds the window to the - oldest retryable row's `ReceivedAt` — otherwise the email could never be - re-fetched. Once the cap is reached the row is terminal, so an email Claude - can never parse stops costing API calls. A failure is any error from the - classify call — Python down, a 502, a 503 because `CLAUDE_API_KEY` is unset - — so an outage of the Python service uses up attempts just as an Anthropic - outage does. The one exception is a cancelled sync, which records nothing. -- **Authenticating email after start-up does not start the scheduler**, which - only checks readiness once — restart, or trigger syncs by hand. - **Introspection and the playground are off** unless `DEV_MODE=true` *and* `GQL_INTROSPECTION` / `GQL_PLAYGROUND` are set. - **No graceful shutdown.** `r.Run` blocks forever and its error is ignored; @@ -531,20 +348,15 @@ warning block at the end of the file. | `SEED_DB` | seed dev test data (never in production) | | `GQL_INTROSPECTION` / `GQL_PLAYGROUND` | dev-only GraphQL extras | | `SPOTIFY_CLIENT_ID` / `_SECRET` / `_REDIRECT_URI` / `SPOTIFY_AUTH_STATE` | Spotify OAuth | -| `PYTHON_HOST` / `PYTHON_PORT` | Python service, for the four Claude routes (default `python:8000`) | +| `PYTHON_HOST` / `PYTHON_PORT` | Python service, for the rowing photo reader (default `python:8000`) | | `GITEA_HOST` / `GITEA_PORT` | Gitea activity feed | | `STEAM_API_KEY` / `STEAM_ID` | Steam presence | -| `EMAIL_SYNC_ENABLED` / `EMAIL_BACKEND` / `EMAIL_SYNC_INTERVAL` | email pipeline (`graph` or `imap`) | -| `JOB_LEADS_ENABLED` / `JOB_LEADS_INTERVAL` | lead pipeline timer (default off, `6h`) | -| `ADZUNA_APP_ID` / `ADZUNA_APP_KEY` / `REED_API_KEY` | keyword-search lead sources; optional | -| `MSGRAPH_CLIENT_ID` / `_SECRET` / `_TENANT_ID` / `_REDIRECT_URI` | Microsoft Graph backend | -| `IMAP_HOST` / `_PORT` / `_EMAIL` / `_PASSWORD` | IMAP backend | Paths baked into the code, all inside mounted volumes so they survive a container restart: `/backend/logs`, `/backend/notes`, `/backend/uploads`, -`/backend/fallback_music`, `/backend/token/` (Spotify and Microsoft Graph -OAuth tokens). +`/backend/fallback_music`, `/backend/token/` (the Spotify OAuth token). `CLAUDE_API_KEY` is not in the table: the backend does not read it. It is in -the registry with `services: ["python"]`, because the Python service is the -only container that uses it. +the registry with `services: ["python", "jobs"]`, the two containers that use +it. The email and job-lead variables still in `.env` belong to the job +tracker (`jobs`), which has its own repo and README. diff --git a/backend/gqlgen.yml b/backend/gqlgen.yml index d48865b..62c8bee 100644 --- a/backend/gqlgen.yml +++ b/backend/gqlgen.yml @@ -26,13 +26,6 @@ models: model: - github.com/99designs/gqlgen/graphql.IntID - github.com/99designs/gqlgen/graphql.UintID - # Bound to MarshalJobStatus / UnmarshalJobStatus in services, so the Go - # type stays `string` (models.JobApplication.Status binds as it is) and the - # marshaller, not a generated enum type, decides what is accepted and what - # is emitted. See services/job_status.go for why. - JobStatus: - model: - - adam-french.co.uk/backend/services.JobStatus User: model: - adam-french.co.uk/backend/models.User @@ -77,30 +70,6 @@ models: fields: deletedAt: resolver: false - JobApplication: - model: - - adam-french.co.uk/backend/models.JobApplication - fields: - deletedAt: - resolver: false - JobAppReference: - model: - - adam-french.co.uk/backend/models.JobAppReference - fields: - deletedAt: - resolver: false - JobSource: - model: - - adam-french.co.uk/backend/models.JobSource - fields: - deletedAt: - resolver: false - JobLead: - model: - - adam-french.co.uk/backend/models.JobLead - JobSearchProfile: - model: - - adam-french.co.uk/backend/models.JobSearchProfile Place: model: - adam-french.co.uk/backend/models.Place diff --git a/backend/graph/directives_test.go b/backend/graph/directives_test.go index 417451d..04c9c84 100644 --- a/backend/graph/directives_test.go +++ b/backend/graph/directives_test.go @@ -187,17 +187,9 @@ func TestSignedInMutationsArePinned(t *testing.T) { // `spotifyNeedsReauth` is false for non-admins. func TestGuardedQueriesArePinned(t *testing.T) { want := map[string]string{ - "users": "admin", - "user": "admin", - "jobApplications": "admin", - "jobApplication": "admin", - "jobAppReferences": "admin", - "jobSources": "admin", - "jobLeads": "admin", - "jobLead": "admin", - "jobSearchProfile": "admin", - "jobLeadSyncStatus": "admin", - "places": "signedIn", + "users": "admin", + "user": "admin", + "places": "signedIn", } got := map[string]string{} for _, field := range schemaUnderTest().Query.Fields { @@ -283,8 +275,8 @@ func TestGuardedFieldsRefuseOverTheWire(t *testing.T) { want string }{ {"anonymous admin query", context.Background(), `{ users { id } }`, "admin access required"}, - {"non-admin admin query", withClaims(2, false), `{ jobApplications { id } }`, "admin access required"}, - {"anonymous admin mutation", context.Background(), `mutation { deleteJobApplication(id: 1) }`, "admin access required"}, + {"non-admin admin query", withClaims(2, false), `{ users { id } }`, "admin access required"}, + {"anonymous admin mutation", context.Background(), `mutation { deleteBookmark(id: 1) { id } }`, "admin access required"}, {"non-admin admin mutation", withClaims(2, false), `mutation { deleteUser(id: 1) { id } }`, "admin access required"}, {"anonymous signed-in query", context.Background(), `{ places { id } }`, "authentication required"}, {"anonymous signed-in mutation", context.Background(), `mutation { deletePlace(id: 1) { id } }`, "authentication required"}, @@ -301,40 +293,6 @@ func TestGuardedFieldsRefuseOverTheWire(t *testing.T) { } } -// The JobStatus enum over the wire, from the side the tracker page uses it: -// status sent as a JSON string variable. A value in the vocabulary reaches the -// resolver (shown by the resolver's own validation error, which comes before -// any database access); one outside it is refused before the resolver runs. -func TestJobStatusInputOverTheWire(t *testing.T) { - const mutation = `mutation ($input: CreateJobApplicationInput!) { createJobApplication(input: $input) { id status } }` - admin := withClaims(1, true) - input := func(status any) map[string]any { - // A blank title makes the resolver return early, so no test here - // needs a database. - return map[string]any{"input": map[string]any{"jobTitle": " ", "company": "Acme", "status": status}} - } - - for _, status := range []string{"saved", "applied", "screening", "assessment", "interviewing", "offer", "rejected", "withdrawn"} { - got := execute(t, admin, mutation, input(status)) - if !slices.Equal(got, []string{"jobTitle and company are required"}) { - t.Errorf("status %q: errors = %q, want it accepted and the resolver reached", status, got) - } - } - - for _, status := range []any{"hired", "Applied", "", " applied", 3} { - got := execute(t, admin, mutation, input(status)) - if len(got) != 1 || got[0] == "jobTitle and company are required" { - t.Errorf("status %#v: errors = %q, want it refused before the resolver", status, got) - } - } - - // The guard still comes first: an anonymous caller learns nothing about - // the vocabulary from a valid input. - if got := execute(t, context.Background(), mutation, input("applied")); !slices.Equal(got, []string{"admin access required"}) { - t.Errorf("anonymous: errors = %q", got) - } -} - // IDs: the wire form must be what it was when every type had a hand-written // resolver returning int. Both marshallers write a quoted decimal string and // both read a string or a number. diff --git a/backend/graph/doc.go b/backend/graph/doc.go index 9e8dcca..f2f43a1 100644 --- a/backend/graph/doc.go +++ b/backend/graph/doc.go @@ -14,8 +14,6 @@ // needed for it. A field resolver is only written where the Go type has // no binding (Message.authorId and Rowing's time/distance are unsigned in // Go and Int in the schema). -// - The JobStatus enum is bound to a custom marshaller in -// services/job_status.go rather than a generated type; see that file. // - Resolvers reach the database and the third-party caches through // Resolver.Store, the same handlers.Store the REST endpoints use. // - context.go and middleware.go carry the caller's identity from Gin into @@ -36,8 +34,8 @@ // // The rule of thumb in this schema is that queries are public and mutations // are @admin, with these exceptions: login, logout and refreshToken are -// public; the places mutations and query are @signedIn; and the users, job -// application and job reference queries are @admin (they are private data). +// public; the places mutations and query are @signedIn; and the users +// queries are @admin (they are private data). // directives_test.go holds that list and fails when the schema departs from // it — in particular when a mutation is added with no directive. // diff --git a/backend/graph/generated.go b/backend/graph/generated.go index b56ff4c..9248373 100644 --- a/backend/graph/generated.go +++ b/backend/graph/generated.go @@ -15,7 +15,6 @@ import ( "adam-french.co.uk/backend/graph/model" "adam-french.co.uk/backend/models" - "adam-french.co.uk/backend/services" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/introspection" gqlparser "github.com/vektah/gqlparser/v2" @@ -84,79 +83,6 @@ type ComplexityRoot struct { RepoURL func(childComplexity int) int } - JobAppReference struct { - Category func(childComplexity int) int - CreatedAt func(childComplexity int) int - ID func(childComplexity int) int - Label func(childComplexity int) int - SortOrder func(childComplexity int) int - UpdatedAt func(childComplexity int) int - Value func(childComplexity int) int - } - - JobApplication struct { - AppliedAt func(childComplexity int) int - Company func(childComplexity int) int - CreatedAt func(childComplexity int) int - Description func(childComplexity int) int - ID func(childComplexity int) int - JobTitle func(childComplexity int) int - Location func(childComplexity int) int - Notes func(childComplexity int) int - Status func(childComplexity int) int - URL func(childComplexity int) int - UpdatedAt func(childComplexity int) int - } - - JobLead struct { - Company func(childComplexity int) int - CreatedAt func(childComplexity int) int - Description func(childComplexity int) int - ID func(childComplexity int) int - JobAppID func(childComplexity int) int - JobTitle func(childComplexity int) int - LastSeenAt func(childComplexity int) int - Location func(childComplexity int) int - Matched func(childComplexity int) int - PostedAt func(childComplexity int) int - Score func(childComplexity int) int - ScoreReasons func(childComplexity int) int - ScoredAt func(childComplexity int) int - SourceKind func(childComplexity int) int - State func(childComplexity int) int - URL func(childComplexity int) int - } - - JobLeadSyncStatus struct { - LastError func(childComplexity int) int - LastRunAt func(childComplexity int) int - Running func(childComplexity int) int - } - - JobSearchProfile struct { - ExcludeKeywords func(childComplexity int) int - IncludeKeywords func(childComplexity int) int - Locations func(childComplexity int) int - MinScore func(childComplexity int) int - Profile func(childComplexity int) int - UpdatedAt func(childComplexity int) int - } - - JobSource struct { - CreatedAt func(childComplexity int) int - Enabled func(childComplexity int) int - ID func(childComplexity int) int - Kind func(childComplexity int) int - Label func(childComplexity int) int - LastCount func(childComplexity int) int - LastError func(childComplexity int) int - LastFetchedAt func(childComplexity int) int - Location func(childComplexity int) int - Query func(childComplexity int) int - Token func(childComplexity int) int - UpdatedAt func(childComplexity int) int - } - Message struct { AuthorID func(childComplexity int) int Content func(childComplexity int) int @@ -167,38 +93,22 @@ type ComplexityRoot struct { } Mutation struct { - CreateActivity func(childComplexity int, input model.CreateActivityInput) int - CreateBookmark func(childComplexity int, input model.CreateBookmarkInput) int - CreateFavorite func(childComplexity int, input model.CreateFavoriteInput) int - CreateJobAppReference func(childComplexity int, input model.CreateJobAppReferenceInput) int - CreateJobApplication func(childComplexity int, input model.CreateJobApplicationInput) int - CreateJobSource func(childComplexity int, input model.CreateJobSourceInput) int - CreatePlace func(childComplexity int, input model.CreatePlaceInput) int - CreatePost func(childComplexity int, input model.CreatePostInput) int - CreateUser func(childComplexity int, input model.CreateUserInput) int - DeleteBookmark func(childComplexity int, id int) int - DeleteJobAppReference func(childComplexity int, id int) int - DeleteJobApplication func(childComplexity int, id int) int - DeleteJobSource func(childComplexity int, id int) int - DeletePlace func(childComplexity int, id int) int - DeletePost func(childComplexity int, id int) int - DeleteUser func(childComplexity int, id int) int - DismissJobLead func(childComplexity int, id int) int - Login func(childComplexity int, input model.LoginInput) int - Logout func(childComplexity int) int - PromoteJobLead func(childComplexity int, id int) int - RefreshToken func(childComplexity int) int - RescoreJobLeads func(childComplexity int) int - RestoreJobLead func(childComplexity int, id int) int - RunJobLeadSync func(childComplexity int) int - ScoreJobLeads func(childComplexity int) int - SetUserAdmin func(childComplexity int, id int, admin bool) int - UpdateJobAppReference func(childComplexity int, id int, input model.UpdateJobAppReferenceInput) int - UpdateJobApplication func(childComplexity int, id int, input model.UpdateJobApplicationInput) int - UpdateJobSearchProfile func(childComplexity int, input model.UpdateJobSearchProfileInput) int - UpdateJobSource func(childComplexity int, id int, input model.UpdateJobSourceInput) int - UpdatePlace func(childComplexity int, id int, input model.UpdatePlaceInput) int - UpdatePost func(childComplexity int, id int, input model.UpdatePostInput) int + CreateActivity func(childComplexity int, input model.CreateActivityInput) int + CreateBookmark func(childComplexity int, input model.CreateBookmarkInput) int + CreateFavorite func(childComplexity int, input model.CreateFavoriteInput) int + CreatePlace func(childComplexity int, input model.CreatePlaceInput) int + CreatePost func(childComplexity int, input model.CreatePostInput) int + CreateUser func(childComplexity int, input model.CreateUserInput) int + DeleteBookmark func(childComplexity int, id int) int + DeletePlace func(childComplexity int, id int) int + DeletePost func(childComplexity int, id int) int + DeleteUser func(childComplexity int, id int) int + Login func(childComplexity int, input model.LoginInput) int + Logout func(childComplexity int) int + RefreshToken func(childComplexity int) int + SetUserAdmin func(childComplexity int, id int, admin bool) int + UpdatePlace func(childComplexity int, id int, input model.UpdatePlaceInput) int + UpdatePost func(childComplexity int, id int, input model.UpdatePostInput) int } Place struct { @@ -229,14 +139,6 @@ type ComplexityRoot struct { Bookmarks func(childComplexity int) int Favorites func(childComplexity int) int GiteaFeed func(childComplexity int) int - JobAppReferences func(childComplexity int) int - JobApplication func(childComplexity int, id int) int - JobApplications func(childComplexity int) int - JobLead func(childComplexity int, id int) int - JobLeadSyncStatus func(childComplexity int) int - JobLeads func(childComplexity int, state *string, includeUnmatched *bool) int - JobSearchProfile func(childComplexity int) int - JobSources func(childComplexity int) int Me func(childComplexity int) int Messages func(childComplexity int) int Places func(childComplexity int) int @@ -327,22 +229,6 @@ type MutationResolver interface { CreateBookmark(ctx context.Context, input model.CreateBookmarkInput) (*models.Bookmark, error) DeleteBookmark(ctx context.Context, id int) (*models.Bookmark, error) CreateFavorite(ctx context.Context, input model.CreateFavoriteInput) (*models.Favorite, error) - CreateJobAppReference(ctx context.Context, input model.CreateJobAppReferenceInput) (*models.JobAppReference, error) - UpdateJobAppReference(ctx context.Context, id int, input model.UpdateJobAppReferenceInput) (*models.JobAppReference, error) - DeleteJobAppReference(ctx context.Context, id int) (bool, error) - CreateJobApplication(ctx context.Context, input model.CreateJobApplicationInput) (*models.JobApplication, error) - UpdateJobApplication(ctx context.Context, id int, input model.UpdateJobApplicationInput) (*models.JobApplication, error) - DeleteJobApplication(ctx context.Context, id int) (bool, error) - CreateJobSource(ctx context.Context, input model.CreateJobSourceInput) (*models.JobSource, error) - UpdateJobSource(ctx context.Context, id int, input model.UpdateJobSourceInput) (*models.JobSource, error) - DeleteJobSource(ctx context.Context, id int) (bool, error) - DismissJobLead(ctx context.Context, id int) (*models.JobLead, error) - RestoreJobLead(ctx context.Context, id int) (*models.JobLead, error) - PromoteJobLead(ctx context.Context, id int) (*models.JobLead, error) - UpdateJobSearchProfile(ctx context.Context, input model.UpdateJobSearchProfileInput) (*models.JobSearchProfile, error) - RunJobLeadSync(ctx context.Context) (bool, error) - ScoreJobLeads(ctx context.Context) (bool, error) - RescoreJobLeads(ctx context.Context) (bool, error) CreatePlace(ctx context.Context, input model.CreatePlaceInput) (*models.Place, error) UpdatePlace(ctx context.Context, id int, input model.UpdatePlaceInput) (*models.Place, error) DeletePlace(ctx context.Context, id int) (*models.Place, error) @@ -359,14 +245,6 @@ type QueryResolver interface { Bookmarks(ctx context.Context) ([]*models.Bookmark, error) Favorites(ctx context.Context) ([]*models.Favorite, error) GiteaFeed(ctx context.Context) (*model.GiteaFeedItem, error) - JobAppReferences(ctx context.Context) ([]*models.JobAppReference, error) - JobApplications(ctx context.Context) ([]*models.JobApplication, error) - JobApplication(ctx context.Context, id int) (*models.JobApplication, error) - JobSources(ctx context.Context) ([]*models.JobSource, error) - JobLeads(ctx context.Context, state *string, includeUnmatched *bool) ([]*models.JobLead, error) - JobLead(ctx context.Context, id int) (*models.JobLead, error) - JobSearchProfile(ctx context.Context) (*models.JobSearchProfile, error) - JobLeadSyncStatus(ctx context.Context) (*model.JobLeadSyncStatus, error) Messages(ctx context.Context) ([]*models.Message, error) Places(ctx context.Context) ([]*models.Place, error) Posts(ctx context.Context) ([]*models.Post, error) @@ -557,342 +435,6 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.ComplexityRoot.GiteaFeedItem.RepoURL(childComplexity), true - case "JobAppReference.category": - if e.ComplexityRoot.JobAppReference.Category == nil { - break - } - - return e.ComplexityRoot.JobAppReference.Category(childComplexity), true - case "JobAppReference.createdAt": - if e.ComplexityRoot.JobAppReference.CreatedAt == nil { - break - } - - return e.ComplexityRoot.JobAppReference.CreatedAt(childComplexity), true - case "JobAppReference.id": - if e.ComplexityRoot.JobAppReference.ID == nil { - break - } - - return e.ComplexityRoot.JobAppReference.ID(childComplexity), true - case "JobAppReference.label": - if e.ComplexityRoot.JobAppReference.Label == nil { - break - } - - return e.ComplexityRoot.JobAppReference.Label(childComplexity), true - case "JobAppReference.sortOrder": - if e.ComplexityRoot.JobAppReference.SortOrder == nil { - break - } - - return e.ComplexityRoot.JobAppReference.SortOrder(childComplexity), true - case "JobAppReference.updatedAt": - if e.ComplexityRoot.JobAppReference.UpdatedAt == nil { - break - } - - return e.ComplexityRoot.JobAppReference.UpdatedAt(childComplexity), true - case "JobAppReference.value": - if e.ComplexityRoot.JobAppReference.Value == nil { - break - } - - return e.ComplexityRoot.JobAppReference.Value(childComplexity), true - - case "JobApplication.appliedAt": - if e.ComplexityRoot.JobApplication.AppliedAt == nil { - break - } - - return e.ComplexityRoot.JobApplication.AppliedAt(childComplexity), true - case "JobApplication.company": - if e.ComplexityRoot.JobApplication.Company == nil { - break - } - - return e.ComplexityRoot.JobApplication.Company(childComplexity), true - case "JobApplication.createdAt": - if e.ComplexityRoot.JobApplication.CreatedAt == nil { - break - } - - return e.ComplexityRoot.JobApplication.CreatedAt(childComplexity), true - case "JobApplication.description": - if e.ComplexityRoot.JobApplication.Description == nil { - break - } - - return e.ComplexityRoot.JobApplication.Description(childComplexity), true - case "JobApplication.id": - if e.ComplexityRoot.JobApplication.ID == nil { - break - } - - return e.ComplexityRoot.JobApplication.ID(childComplexity), true - case "JobApplication.jobTitle": - if e.ComplexityRoot.JobApplication.JobTitle == nil { - break - } - - return e.ComplexityRoot.JobApplication.JobTitle(childComplexity), true - case "JobApplication.location": - if e.ComplexityRoot.JobApplication.Location == nil { - break - } - - return e.ComplexityRoot.JobApplication.Location(childComplexity), true - case "JobApplication.notes": - if e.ComplexityRoot.JobApplication.Notes == nil { - break - } - - return e.ComplexityRoot.JobApplication.Notes(childComplexity), true - case "JobApplication.status": - if e.ComplexityRoot.JobApplication.Status == nil { - break - } - - return e.ComplexityRoot.JobApplication.Status(childComplexity), true - case "JobApplication.url": - if e.ComplexityRoot.JobApplication.URL == nil { - break - } - - return e.ComplexityRoot.JobApplication.URL(childComplexity), true - case "JobApplication.updatedAt": - if e.ComplexityRoot.JobApplication.UpdatedAt == nil { - break - } - - return e.ComplexityRoot.JobApplication.UpdatedAt(childComplexity), true - - case "JobLead.company": - if e.ComplexityRoot.JobLead.Company == nil { - break - } - - return e.ComplexityRoot.JobLead.Company(childComplexity), true - case "JobLead.createdAt": - if e.ComplexityRoot.JobLead.CreatedAt == nil { - break - } - - return e.ComplexityRoot.JobLead.CreatedAt(childComplexity), true - case "JobLead.description": - if e.ComplexityRoot.JobLead.Description == nil { - break - } - - return e.ComplexityRoot.JobLead.Description(childComplexity), true - case "JobLead.id": - if e.ComplexityRoot.JobLead.ID == nil { - break - } - - return e.ComplexityRoot.JobLead.ID(childComplexity), true - case "JobLead.jobAppId": - if e.ComplexityRoot.JobLead.JobAppID == nil { - break - } - - return e.ComplexityRoot.JobLead.JobAppID(childComplexity), true - case "JobLead.jobTitle": - if e.ComplexityRoot.JobLead.JobTitle == nil { - break - } - - return e.ComplexityRoot.JobLead.JobTitle(childComplexity), true - case "JobLead.lastSeenAt": - if e.ComplexityRoot.JobLead.LastSeenAt == nil { - break - } - - return e.ComplexityRoot.JobLead.LastSeenAt(childComplexity), true - case "JobLead.location": - if e.ComplexityRoot.JobLead.Location == nil { - break - } - - return e.ComplexityRoot.JobLead.Location(childComplexity), true - case "JobLead.matched": - if e.ComplexityRoot.JobLead.Matched == nil { - break - } - - return e.ComplexityRoot.JobLead.Matched(childComplexity), true - case "JobLead.postedAt": - if e.ComplexityRoot.JobLead.PostedAt == nil { - break - } - - return e.ComplexityRoot.JobLead.PostedAt(childComplexity), true - case "JobLead.score": - if e.ComplexityRoot.JobLead.Score == nil { - break - } - - return e.ComplexityRoot.JobLead.Score(childComplexity), true - case "JobLead.scoreReasons": - if e.ComplexityRoot.JobLead.ScoreReasons == nil { - break - } - - return e.ComplexityRoot.JobLead.ScoreReasons(childComplexity), true - case "JobLead.scoredAt": - if e.ComplexityRoot.JobLead.ScoredAt == nil { - break - } - - return e.ComplexityRoot.JobLead.ScoredAt(childComplexity), true - case "JobLead.sourceKind": - if e.ComplexityRoot.JobLead.SourceKind == nil { - break - } - - return e.ComplexityRoot.JobLead.SourceKind(childComplexity), true - case "JobLead.state": - if e.ComplexityRoot.JobLead.State == nil { - break - } - - return e.ComplexityRoot.JobLead.State(childComplexity), true - case "JobLead.url": - if e.ComplexityRoot.JobLead.URL == nil { - break - } - - return e.ComplexityRoot.JobLead.URL(childComplexity), true - - case "JobLeadSyncStatus.lastError": - if e.ComplexityRoot.JobLeadSyncStatus.LastError == nil { - break - } - - return e.ComplexityRoot.JobLeadSyncStatus.LastError(childComplexity), true - case "JobLeadSyncStatus.lastRunAt": - if e.ComplexityRoot.JobLeadSyncStatus.LastRunAt == nil { - break - } - - return e.ComplexityRoot.JobLeadSyncStatus.LastRunAt(childComplexity), true - case "JobLeadSyncStatus.running": - if e.ComplexityRoot.JobLeadSyncStatus.Running == nil { - break - } - - return e.ComplexityRoot.JobLeadSyncStatus.Running(childComplexity), true - - case "JobSearchProfile.excludeKeywords": - if e.ComplexityRoot.JobSearchProfile.ExcludeKeywords == nil { - break - } - - return e.ComplexityRoot.JobSearchProfile.ExcludeKeywords(childComplexity), true - case "JobSearchProfile.includeKeywords": - if e.ComplexityRoot.JobSearchProfile.IncludeKeywords == nil { - break - } - - return e.ComplexityRoot.JobSearchProfile.IncludeKeywords(childComplexity), true - case "JobSearchProfile.locations": - if e.ComplexityRoot.JobSearchProfile.Locations == nil { - break - } - - return e.ComplexityRoot.JobSearchProfile.Locations(childComplexity), true - case "JobSearchProfile.minScore": - if e.ComplexityRoot.JobSearchProfile.MinScore == nil { - break - } - - return e.ComplexityRoot.JobSearchProfile.MinScore(childComplexity), true - case "JobSearchProfile.profile": - if e.ComplexityRoot.JobSearchProfile.Profile == nil { - break - } - - return e.ComplexityRoot.JobSearchProfile.Profile(childComplexity), true - case "JobSearchProfile.updatedAt": - if e.ComplexityRoot.JobSearchProfile.UpdatedAt == nil { - break - } - - return e.ComplexityRoot.JobSearchProfile.UpdatedAt(childComplexity), true - - case "JobSource.createdAt": - if e.ComplexityRoot.JobSource.CreatedAt == nil { - break - } - - return e.ComplexityRoot.JobSource.CreatedAt(childComplexity), true - case "JobSource.enabled": - if e.ComplexityRoot.JobSource.Enabled == nil { - break - } - - return e.ComplexityRoot.JobSource.Enabled(childComplexity), true - case "JobSource.id": - if e.ComplexityRoot.JobSource.ID == nil { - break - } - - return e.ComplexityRoot.JobSource.ID(childComplexity), true - case "JobSource.kind": - if e.ComplexityRoot.JobSource.Kind == nil { - break - } - - return e.ComplexityRoot.JobSource.Kind(childComplexity), true - case "JobSource.label": - if e.ComplexityRoot.JobSource.Label == nil { - break - } - - return e.ComplexityRoot.JobSource.Label(childComplexity), true - case "JobSource.lastCount": - if e.ComplexityRoot.JobSource.LastCount == nil { - break - } - - return e.ComplexityRoot.JobSource.LastCount(childComplexity), true - case "JobSource.lastError": - if e.ComplexityRoot.JobSource.LastError == nil { - break - } - - return e.ComplexityRoot.JobSource.LastError(childComplexity), true - case "JobSource.lastFetchedAt": - if e.ComplexityRoot.JobSource.LastFetchedAt == nil { - break - } - - return e.ComplexityRoot.JobSource.LastFetchedAt(childComplexity), true - case "JobSource.location": - if e.ComplexityRoot.JobSource.Location == nil { - break - } - - return e.ComplexityRoot.JobSource.Location(childComplexity), true - case "JobSource.query": - if e.ComplexityRoot.JobSource.Query == nil { - break - } - - return e.ComplexityRoot.JobSource.Query(childComplexity), true - case "JobSource.token": - if e.ComplexityRoot.JobSource.Token == nil { - break - } - - return e.ComplexityRoot.JobSource.Token(childComplexity), true - case "JobSource.updatedAt": - if e.ComplexityRoot.JobSource.UpdatedAt == nil { - break - } - - return e.ComplexityRoot.JobSource.UpdatedAt(childComplexity), true - case "Message.authorId": if e.ComplexityRoot.Message.AuthorID == nil { break @@ -963,39 +505,6 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin } return e.ComplexityRoot.Mutation.CreateFavorite(childComplexity, args["input"].(model.CreateFavoriteInput)), true - case "Mutation.createJobAppReference": - if e.ComplexityRoot.Mutation.CreateJobAppReference == nil { - break - } - - args, err := ec.field_Mutation_createJobAppReference_args(ctx, rawArgs) - if err != nil { - return 0, false - } - - return e.ComplexityRoot.Mutation.CreateJobAppReference(childComplexity, args["input"].(model.CreateJobAppReferenceInput)), true - case "Mutation.createJobApplication": - if e.ComplexityRoot.Mutation.CreateJobApplication == nil { - break - } - - args, err := ec.field_Mutation_createJobApplication_args(ctx, rawArgs) - if err != nil { - return 0, false - } - - return e.ComplexityRoot.Mutation.CreateJobApplication(childComplexity, args["input"].(model.CreateJobApplicationInput)), true - case "Mutation.createJobSource": - if e.ComplexityRoot.Mutation.CreateJobSource == nil { - break - } - - args, err := ec.field_Mutation_createJobSource_args(ctx, rawArgs) - if err != nil { - return 0, false - } - - return e.ComplexityRoot.Mutation.CreateJobSource(childComplexity, args["input"].(model.CreateJobSourceInput)), true case "Mutation.createPlace": if e.ComplexityRoot.Mutation.CreatePlace == nil { break @@ -1040,39 +549,6 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin } return e.ComplexityRoot.Mutation.DeleteBookmark(childComplexity, args["id"].(int)), true - case "Mutation.deleteJobAppReference": - if e.ComplexityRoot.Mutation.DeleteJobAppReference == nil { - break - } - - args, err := ec.field_Mutation_deleteJobAppReference_args(ctx, rawArgs) - if err != nil { - return 0, false - } - - return e.ComplexityRoot.Mutation.DeleteJobAppReference(childComplexity, args["id"].(int)), true - case "Mutation.deleteJobApplication": - if e.ComplexityRoot.Mutation.DeleteJobApplication == nil { - break - } - - args, err := ec.field_Mutation_deleteJobApplication_args(ctx, rawArgs) - if err != nil { - return 0, false - } - - return e.ComplexityRoot.Mutation.DeleteJobApplication(childComplexity, args["id"].(int)), true - case "Mutation.deleteJobSource": - if e.ComplexityRoot.Mutation.DeleteJobSource == nil { - break - } - - args, err := ec.field_Mutation_deleteJobSource_args(ctx, rawArgs) - if err != nil { - return 0, false - } - - return e.ComplexityRoot.Mutation.DeleteJobSource(childComplexity, args["id"].(int)), true case "Mutation.deletePlace": if e.ComplexityRoot.Mutation.DeletePlace == nil { break @@ -1106,17 +582,6 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin } return e.ComplexityRoot.Mutation.DeleteUser(childComplexity, args["id"].(int)), true - case "Mutation.dismissJobLead": - if e.ComplexityRoot.Mutation.DismissJobLead == nil { - break - } - - args, err := ec.field_Mutation_dismissJobLead_args(ctx, rawArgs) - if err != nil { - return 0, false - } - - return e.ComplexityRoot.Mutation.DismissJobLead(childComplexity, args["id"].(int)), true case "Mutation.login": if e.ComplexityRoot.Mutation.Login == nil { break @@ -1134,52 +599,12 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin } return e.ComplexityRoot.Mutation.Logout(childComplexity), true - case "Mutation.promoteJobLead": - if e.ComplexityRoot.Mutation.PromoteJobLead == nil { - break - } - - args, err := ec.field_Mutation_promoteJobLead_args(ctx, rawArgs) - if err != nil { - return 0, false - } - - return e.ComplexityRoot.Mutation.PromoteJobLead(childComplexity, args["id"].(int)), true case "Mutation.refreshToken": if e.ComplexityRoot.Mutation.RefreshToken == nil { break } return e.ComplexityRoot.Mutation.RefreshToken(childComplexity), true - case "Mutation.rescoreJobLeads": - if e.ComplexityRoot.Mutation.RescoreJobLeads == nil { - break - } - - return e.ComplexityRoot.Mutation.RescoreJobLeads(childComplexity), true - case "Mutation.restoreJobLead": - if e.ComplexityRoot.Mutation.RestoreJobLead == nil { - break - } - - args, err := ec.field_Mutation_restoreJobLead_args(ctx, rawArgs) - if err != nil { - return 0, false - } - - return e.ComplexityRoot.Mutation.RestoreJobLead(childComplexity, args["id"].(int)), true - case "Mutation.runJobLeadSync": - if e.ComplexityRoot.Mutation.RunJobLeadSync == nil { - break - } - - return e.ComplexityRoot.Mutation.RunJobLeadSync(childComplexity), true - case "Mutation.scoreJobLeads": - if e.ComplexityRoot.Mutation.ScoreJobLeads == nil { - break - } - - return e.ComplexityRoot.Mutation.ScoreJobLeads(childComplexity), true case "Mutation.setUserAdmin": if e.ComplexityRoot.Mutation.SetUserAdmin == nil { break @@ -1191,50 +616,6 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin } return e.ComplexityRoot.Mutation.SetUserAdmin(childComplexity, args["id"].(int), args["admin"].(bool)), true - case "Mutation.updateJobAppReference": - if e.ComplexityRoot.Mutation.UpdateJobAppReference == nil { - break - } - - args, err := ec.field_Mutation_updateJobAppReference_args(ctx, rawArgs) - if err != nil { - return 0, false - } - - return e.ComplexityRoot.Mutation.UpdateJobAppReference(childComplexity, args["id"].(int), args["input"].(model.UpdateJobAppReferenceInput)), true - case "Mutation.updateJobApplication": - if e.ComplexityRoot.Mutation.UpdateJobApplication == nil { - break - } - - args, err := ec.field_Mutation_updateJobApplication_args(ctx, rawArgs) - if err != nil { - return 0, false - } - - return e.ComplexityRoot.Mutation.UpdateJobApplication(childComplexity, args["id"].(int), args["input"].(model.UpdateJobApplicationInput)), true - case "Mutation.updateJobSearchProfile": - if e.ComplexityRoot.Mutation.UpdateJobSearchProfile == nil { - break - } - - args, err := ec.field_Mutation_updateJobSearchProfile_args(ctx, rawArgs) - if err != nil { - return 0, false - } - - return e.ComplexityRoot.Mutation.UpdateJobSearchProfile(childComplexity, args["input"].(model.UpdateJobSearchProfileInput)), true - case "Mutation.updateJobSource": - if e.ComplexityRoot.Mutation.UpdateJobSource == nil { - break - } - - args, err := ec.field_Mutation_updateJobSource_args(ctx, rawArgs) - if err != nil { - return 0, false - } - - return e.ComplexityRoot.Mutation.UpdateJobSource(childComplexity, args["id"].(int), args["input"].(model.UpdateJobSourceInput)), true case "Mutation.updatePlace": if e.ComplexityRoot.Mutation.UpdatePlace == nil { break @@ -1387,69 +768,6 @@ func (e *executableSchema) Complexity(ctx context.Context, typeName, field strin return e.ComplexityRoot.Query.GiteaFeed(childComplexity), true - case "Query.jobAppReferences": - if e.ComplexityRoot.Query.JobAppReferences == nil { - break - } - - return e.ComplexityRoot.Query.JobAppReferences(childComplexity), true - case "Query.jobApplication": - if e.ComplexityRoot.Query.JobApplication == nil { - break - } - - args, err := ec.field_Query_jobApplication_args(ctx, rawArgs) - if err != nil { - return 0, false - } - - return e.ComplexityRoot.Query.JobApplication(childComplexity, args["id"].(int)), true - case "Query.jobApplications": - if e.ComplexityRoot.Query.JobApplications == nil { - break - } - - return e.ComplexityRoot.Query.JobApplications(childComplexity), true - case "Query.jobLead": - if e.ComplexityRoot.Query.JobLead == nil { - break - } - - args, err := ec.field_Query_jobLead_args(ctx, rawArgs) - if err != nil { - return 0, false - } - - return e.ComplexityRoot.Query.JobLead(childComplexity, args["id"].(int)), true - case "Query.jobLeadSyncStatus": - if e.ComplexityRoot.Query.JobLeadSyncStatus == nil { - break - } - - return e.ComplexityRoot.Query.JobLeadSyncStatus(childComplexity), true - case "Query.jobLeads": - if e.ComplexityRoot.Query.JobLeads == nil { - break - } - - args, err := ec.field_Query_jobLeads_args(ctx, rawArgs) - if err != nil { - return 0, false - } - - return e.ComplexityRoot.Query.JobLeads(childComplexity, args["state"].(*string), args["includeUnmatched"].(*bool)), true - case "Query.jobSearchProfile": - if e.ComplexityRoot.Query.JobSearchProfile == nil { - break - } - - return e.ComplexityRoot.Query.JobSearchProfile(childComplexity), true - case "Query.jobSources": - if e.ComplexityRoot.Query.JobSources == nil { - break - } - - return e.ComplexityRoot.Query.JobSources(childComplexity), true case "Query.me": if e.ComplexityRoot.Query.Me == nil { break @@ -1734,17 +1052,10 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec.unmarshalInputCreateActivityInput, ec.unmarshalInputCreateBookmarkInput, ec.unmarshalInputCreateFavoriteInput, - ec.unmarshalInputCreateJobAppReferenceInput, - ec.unmarshalInputCreateJobApplicationInput, - ec.unmarshalInputCreateJobSourceInput, ec.unmarshalInputCreatePlaceInput, ec.unmarshalInputCreatePostInput, ec.unmarshalInputCreateUserInput, ec.unmarshalInputLoginInput, - ec.unmarshalInputUpdateJobAppReferenceInput, - ec.unmarshalInputUpdateJobApplicationInput, - ec.unmarshalInputUpdateJobSearchProfileInput, - ec.unmarshalInputUpdateJobSourceInput, ec.unmarshalInputUpdatePlaceInput, ec.unmarshalInputUpdatePostInput, ) @@ -1821,7 +1132,7 @@ func newExecutionContext( } } -//go:embed "schema/activity.graphql" "schema/auth.graphql" "schema/bookmark.graphql" "schema/favorite.graphql" "schema/gitea.graphql" "schema/job_app_reference.graphql" "schema/job_application.graphql" "schema/job_lead.graphql" "schema/message.graphql" "schema/place.graphql" "schema/post.graphql" "schema/rowing.graphql" "schema/schema.graphql" "schema/spotify.graphql" "schema/steam.graphql" "schema/user.graphql" +//go:embed "schema/activity.graphql" "schema/auth.graphql" "schema/bookmark.graphql" "schema/favorite.graphql" "schema/gitea.graphql" "schema/message.graphql" "schema/place.graphql" "schema/post.graphql" "schema/rowing.graphql" "schema/schema.graphql" "schema/spotify.graphql" "schema/steam.graphql" "schema/user.graphql" var sourcesFS embed.FS func sourceData(filename string) string { @@ -1838,9 +1149,6 @@ var sources = []*ast.Source{ {Name: "schema/bookmark.graphql", Input: sourceData("schema/bookmark.graphql"), BuiltIn: false}, {Name: "schema/favorite.graphql", Input: sourceData("schema/favorite.graphql"), BuiltIn: false}, {Name: "schema/gitea.graphql", Input: sourceData("schema/gitea.graphql"), BuiltIn: false}, - {Name: "schema/job_app_reference.graphql", Input: sourceData("schema/job_app_reference.graphql"), BuiltIn: false}, - {Name: "schema/job_application.graphql", Input: sourceData("schema/job_application.graphql"), BuiltIn: false}, - {Name: "schema/job_lead.graphql", Input: sourceData("schema/job_lead.graphql"), BuiltIn: false}, {Name: "schema/message.graphql", Input: sourceData("schema/message.graphql"), BuiltIn: false}, {Name: "schema/place.graphql", Input: sourceData("schema/place.graphql"), BuiltIn: false}, {Name: "schema/post.graphql", Input: sourceData("schema/post.graphql"), BuiltIn: false}, @@ -1936,152 +1244,6 @@ func (ec *executionContext) childFields_GiteaFeedItem(ctx context.Context, field return nil, fmt.Errorf("no field named %q was found under type GiteaFeedItem", field.Name) } -func (ec *executionContext) childFields_JobAppReference(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_JobAppReference_id(ctx, field) - case "createdAt": - return ec.fieldContext_JobAppReference_createdAt(ctx, field) - case "updatedAt": - return ec.fieldContext_JobAppReference_updatedAt(ctx, field) - case "category": - return ec.fieldContext_JobAppReference_category(ctx, field) - case "label": - return ec.fieldContext_JobAppReference_label(ctx, field) - case "value": - return ec.fieldContext_JobAppReference_value(ctx, field) - case "sortOrder": - return ec.fieldContext_JobAppReference_sortOrder(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type JobAppReference", field.Name) -} - -func (ec *executionContext) childFields_JobApplication(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_JobApplication_id(ctx, field) - case "createdAt": - return ec.fieldContext_JobApplication_createdAt(ctx, field) - case "updatedAt": - return ec.fieldContext_JobApplication_updatedAt(ctx, field) - case "jobTitle": - return ec.fieldContext_JobApplication_jobTitle(ctx, field) - case "company": - return ec.fieldContext_JobApplication_company(ctx, field) - case "location": - return ec.fieldContext_JobApplication_location(ctx, field) - case "url": - return ec.fieldContext_JobApplication_url(ctx, field) - case "status": - return ec.fieldContext_JobApplication_status(ctx, field) - case "notes": - return ec.fieldContext_JobApplication_notes(ctx, field) - case "appliedAt": - return ec.fieldContext_JobApplication_appliedAt(ctx, field) - case "description": - return ec.fieldContext_JobApplication_description(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type JobApplication", field.Name) -} - -func (ec *executionContext) childFields_JobLead(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_JobLead_id(ctx, field) - case "createdAt": - return ec.fieldContext_JobLead_createdAt(ctx, field) - case "sourceKind": - return ec.fieldContext_JobLead_sourceKind(ctx, field) - case "jobTitle": - return ec.fieldContext_JobLead_jobTitle(ctx, field) - case "company": - return ec.fieldContext_JobLead_company(ctx, field) - case "location": - return ec.fieldContext_JobLead_location(ctx, field) - case "url": - return ec.fieldContext_JobLead_url(ctx, field) - case "description": - return ec.fieldContext_JobLead_description(ctx, field) - case "postedAt": - return ec.fieldContext_JobLead_postedAt(ctx, field) - case "lastSeenAt": - return ec.fieldContext_JobLead_lastSeenAt(ctx, field) - case "matched": - return ec.fieldContext_JobLead_matched(ctx, field) - case "state": - return ec.fieldContext_JobLead_state(ctx, field) - case "score": - return ec.fieldContext_JobLead_score(ctx, field) - case "scoreReasons": - return ec.fieldContext_JobLead_scoreReasons(ctx, field) - case "scoredAt": - return ec.fieldContext_JobLead_scoredAt(ctx, field) - case "jobAppId": - return ec.fieldContext_JobLead_jobAppId(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type JobLead", field.Name) -} - -func (ec *executionContext) childFields_JobLeadSyncStatus(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "running": - return ec.fieldContext_JobLeadSyncStatus_running(ctx, field) - case "lastRunAt": - return ec.fieldContext_JobLeadSyncStatus_lastRunAt(ctx, field) - case "lastError": - return ec.fieldContext_JobLeadSyncStatus_lastError(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type JobLeadSyncStatus", field.Name) -} - -func (ec *executionContext) childFields_JobSearchProfile(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "updatedAt": - return ec.fieldContext_JobSearchProfile_updatedAt(ctx, field) - case "profile": - return ec.fieldContext_JobSearchProfile_profile(ctx, field) - case "includeKeywords": - return ec.fieldContext_JobSearchProfile_includeKeywords(ctx, field) - case "excludeKeywords": - return ec.fieldContext_JobSearchProfile_excludeKeywords(ctx, field) - case "locations": - return ec.fieldContext_JobSearchProfile_locations(ctx, field) - case "minScore": - return ec.fieldContext_JobSearchProfile_minScore(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type JobSearchProfile", field.Name) -} - -func (ec *executionContext) childFields_JobSource(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "id": - return ec.fieldContext_JobSource_id(ctx, field) - case "createdAt": - return ec.fieldContext_JobSource_createdAt(ctx, field) - case "updatedAt": - return ec.fieldContext_JobSource_updatedAt(ctx, field) - case "kind": - return ec.fieldContext_JobSource_kind(ctx, field) - case "label": - return ec.fieldContext_JobSource_label(ctx, field) - case "token": - return ec.fieldContext_JobSource_token(ctx, field) - case "query": - return ec.fieldContext_JobSource_query(ctx, field) - case "location": - return ec.fieldContext_JobSource_location(ctx, field) - case "enabled": - return ec.fieldContext_JobSource_enabled(ctx, field) - case "lastFetchedAt": - return ec.fieldContext_JobSource_lastFetchedAt(ctx, field) - case "lastCount": - return ec.fieldContext_JobSource_lastCount(ctx, field) - case "lastError": - return ec.fieldContext_JobSource_lastError(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type JobSource", field.Name) -} - func (ec *executionContext) childFields_Message(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "id": @@ -2424,48 +1586,6 @@ func (ec *executionContext) field_Mutation_createFavorite_args(ctx context.Conte return args, nil } -func (ec *executionContext) field_Mutation_createJobAppReference_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { - var err error - args := map[string]any{} - arg0, err := graphql.ProcessArgField(ctx, rawArgs, "input", - func(ctx context.Context, v any) (model.CreateJobAppReferenceInput, error) { - return ec.unmarshalNCreateJobAppReferenceInput2adamᚑfrenchᚗcoᚗukᚋbackendᚋgraphᚋmodelᚐCreateJobAppReferenceInput(ctx, v) - }) - if err != nil { - return nil, err - } - args["input"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_createJobApplication_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { - var err error - args := map[string]any{} - arg0, err := graphql.ProcessArgField(ctx, rawArgs, "input", - func(ctx context.Context, v any) (model.CreateJobApplicationInput, error) { - return ec.unmarshalNCreateJobApplicationInput2adamᚑfrenchᚗcoᚗukᚋbackendᚋgraphᚋmodelᚐCreateJobApplicationInput(ctx, v) - }) - if err != nil { - return nil, err - } - args["input"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_createJobSource_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { - var err error - args := map[string]any{} - arg0, err := graphql.ProcessArgField(ctx, rawArgs, "input", - func(ctx context.Context, v any) (model.CreateJobSourceInput, error) { - return ec.unmarshalNCreateJobSourceInput2adamᚑfrenchᚗcoᚗukᚋbackendᚋgraphᚋmodelᚐCreateJobSourceInput(ctx, v) - }) - if err != nil { - return nil, err - } - args["input"] = arg0 - return args, nil -} - func (ec *executionContext) field_Mutation_createPlace_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -2522,48 +1642,6 @@ func (ec *executionContext) field_Mutation_deleteBookmark_args(ctx context.Conte return args, nil } -func (ec *executionContext) field_Mutation_deleteJobAppReference_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { - var err error - args := map[string]any{} - arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", - func(ctx context.Context, v any) (int, error) { - return ec.unmarshalNID2int(ctx, v) - }) - if err != nil { - return nil, err - } - args["id"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_deleteJobApplication_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { - var err error - args := map[string]any{} - arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", - func(ctx context.Context, v any) (int, error) { - return ec.unmarshalNID2int(ctx, v) - }) - if err != nil { - return nil, err - } - args["id"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_deleteJobSource_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { - var err error - args := map[string]any{} - arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", - func(ctx context.Context, v any) (int, error) { - return ec.unmarshalNID2int(ctx, v) - }) - if err != nil { - return nil, err - } - args["id"] = arg0 - return args, nil -} - func (ec *executionContext) field_Mutation_deletePlace_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -2606,20 +1684,6 @@ func (ec *executionContext) field_Mutation_deleteUser_args(ctx context.Context, return args, nil } -func (ec *executionContext) field_Mutation_dismissJobLead_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { - var err error - args := map[string]any{} - arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", - func(ctx context.Context, v any) (int, error) { - return ec.unmarshalNID2int(ctx, v) - }) - if err != nil { - return nil, err - } - args["id"] = arg0 - return args, nil -} - func (ec *executionContext) field_Mutation_login_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -2634,34 +1698,6 @@ func (ec *executionContext) field_Mutation_login_args(ctx context.Context, rawAr return args, nil } -func (ec *executionContext) field_Mutation_promoteJobLead_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { - var err error - args := map[string]any{} - arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", - func(ctx context.Context, v any) (int, error) { - return ec.unmarshalNID2int(ctx, v) - }) - if err != nil { - return nil, err - } - args["id"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_restoreJobLead_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { - var err error - args := map[string]any{} - arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", - func(ctx context.Context, v any) (int, error) { - return ec.unmarshalNID2int(ctx, v) - }) - if err != nil { - return nil, err - } - args["id"] = arg0 - return args, nil -} - func (ec *executionContext) field_Mutation_setUserAdmin_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -2684,86 +1720,6 @@ func (ec *executionContext) field_Mutation_setUserAdmin_args(ctx context.Context return args, nil } -func (ec *executionContext) field_Mutation_updateJobAppReference_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { - var err error - args := map[string]any{} - arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", - func(ctx context.Context, v any) (int, error) { - return ec.unmarshalNID2int(ctx, v) - }) - if err != nil { - return nil, err - } - args["id"] = arg0 - arg1, err := graphql.ProcessArgField(ctx, rawArgs, "input", - func(ctx context.Context, v any) (model.UpdateJobAppReferenceInput, error) { - return ec.unmarshalNUpdateJobAppReferenceInput2adamᚑfrenchᚗcoᚗukᚋbackendᚋgraphᚋmodelᚐUpdateJobAppReferenceInput(ctx, v) - }) - if err != nil { - return nil, err - } - args["input"] = arg1 - return args, nil -} - -func (ec *executionContext) field_Mutation_updateJobApplication_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { - var err error - args := map[string]any{} - arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", - func(ctx context.Context, v any) (int, error) { - return ec.unmarshalNID2int(ctx, v) - }) - if err != nil { - return nil, err - } - args["id"] = arg0 - arg1, err := graphql.ProcessArgField(ctx, rawArgs, "input", - func(ctx context.Context, v any) (model.UpdateJobApplicationInput, error) { - return ec.unmarshalNUpdateJobApplicationInput2adamᚑfrenchᚗcoᚗukᚋbackendᚋgraphᚋmodelᚐUpdateJobApplicationInput(ctx, v) - }) - if err != nil { - return nil, err - } - args["input"] = arg1 - return args, nil -} - -func (ec *executionContext) field_Mutation_updateJobSearchProfile_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { - var err error - args := map[string]any{} - arg0, err := graphql.ProcessArgField(ctx, rawArgs, "input", - func(ctx context.Context, v any) (model.UpdateJobSearchProfileInput, error) { - return ec.unmarshalNUpdateJobSearchProfileInput2adamᚑfrenchᚗcoᚗukᚋbackendᚋgraphᚋmodelᚐUpdateJobSearchProfileInput(ctx, v) - }) - if err != nil { - return nil, err - } - args["input"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Mutation_updateJobSource_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { - var err error - args := map[string]any{} - arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", - func(ctx context.Context, v any) (int, error) { - return ec.unmarshalNID2int(ctx, v) - }) - if err != nil { - return nil, err - } - args["id"] = arg0 - arg1, err := graphql.ProcessArgField(ctx, rawArgs, "input", - func(ctx context.Context, v any) (model.UpdateJobSourceInput, error) { - return ec.unmarshalNUpdateJobSourceInput2adamᚑfrenchᚗcoᚗukᚋbackendᚋgraphᚋmodelᚐUpdateJobSourceInput(ctx, v) - }) - if err != nil { - return nil, err - } - args["input"] = arg1 - return args, nil -} - func (ec *executionContext) field_Mutation_updatePlace_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -2822,56 +1778,6 @@ func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs return args, nil } -func (ec *executionContext) field_Query_jobApplication_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { - var err error - args := map[string]any{} - arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", - func(ctx context.Context, v any) (int, error) { - return ec.unmarshalNID2int(ctx, v) - }) - if err != nil { - return nil, err - } - args["id"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Query_jobLead_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { - var err error - args := map[string]any{} - arg0, err := graphql.ProcessArgField(ctx, rawArgs, "id", - func(ctx context.Context, v any) (int, error) { - return ec.unmarshalNID2int(ctx, v) - }) - if err != nil { - return nil, err - } - args["id"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Query_jobLeads_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { - var err error - args := map[string]any{} - arg0, err := graphql.ProcessArgField(ctx, rawArgs, "state", - func(ctx context.Context, v any) (*string, error) { - return ec.unmarshalOString2ᚖstring(ctx, v) - }) - if err != nil { - return nil, err - } - args["state"] = arg0 - arg1, err := graphql.ProcessArgField(ctx, rawArgs, "includeUnmatched", - func(ctx context.Context, v any) (*bool, error) { - return ec.unmarshalOBoolean2ᚖbool(ctx, v) - }) - if err != nil { - return nil, err - } - args["includeUnmatched"] = arg1 - return args, nil -} - func (ec *executionContext) field_Query_post_args(ctx context.Context, rawArgs map[string]any) (map[string]any, error) { var err error args := map[string]any{} @@ -3544,1271 +2450,6 @@ func (ec *executionContext) fieldContext_GiteaFeedItem_createdAt(_ context.Conte return graphql.NewScalarFieldContext("GiteaFeedItem", field, false, false, errors.New("field of type Time does not have child fields")) } -func (ec *executionContext) _JobAppReference_id(ctx context.Context, field graphql.CollectedField, obj *models.JobAppReference) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobAppReference_id(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.ID, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v uint) graphql.Marshaler { - return ec.marshalNID2uint(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobAppReference_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobAppReference", field, false, false, errors.New("field of type ID does not have child fields")) -} - -func (ec *executionContext) _JobAppReference_createdAt(ctx context.Context, field graphql.CollectedField, obj *models.JobAppReference) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobAppReference_createdAt(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v time.Time) graphql.Marshaler { - return ec.marshalNTime2timeᚐTime(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobAppReference_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobAppReference", field, false, false, errors.New("field of type Time does not have child fields")) -} - -func (ec *executionContext) _JobAppReference_updatedAt(ctx context.Context, field graphql.CollectedField, obj *models.JobAppReference) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobAppReference_updatedAt(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.UpdatedAt, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v time.Time) graphql.Marshaler { - return ec.marshalNTime2timeᚐTime(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobAppReference_updatedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobAppReference", field, false, false, errors.New("field of type Time does not have child fields")) -} - -func (ec *executionContext) _JobAppReference_category(ctx context.Context, field graphql.CollectedField, obj *models.JobAppReference) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobAppReference_category(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Category, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobAppReference_category(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobAppReference", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _JobAppReference_label(ctx context.Context, field graphql.CollectedField, obj *models.JobAppReference) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobAppReference_label(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Label, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobAppReference_label(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobAppReference", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _JobAppReference_value(ctx context.Context, field graphql.CollectedField, obj *models.JobAppReference) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobAppReference_value(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Value, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobAppReference_value(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobAppReference", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _JobAppReference_sortOrder(ctx context.Context, field graphql.CollectedField, obj *models.JobAppReference) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobAppReference_sortOrder(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.SortOrder, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v int) graphql.Marshaler { - return ec.marshalNInt2int(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobAppReference_sortOrder(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobAppReference", field, false, false, errors.New("field of type Int does not have child fields")) -} - -func (ec *executionContext) _JobApplication_id(ctx context.Context, field graphql.CollectedField, obj *models.JobApplication) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobApplication_id(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.ID, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v uint) graphql.Marshaler { - return ec.marshalNID2uint(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobApplication_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobApplication", field, false, false, errors.New("field of type ID does not have child fields")) -} - -func (ec *executionContext) _JobApplication_createdAt(ctx context.Context, field graphql.CollectedField, obj *models.JobApplication) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobApplication_createdAt(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v time.Time) graphql.Marshaler { - return ec.marshalNTime2timeᚐTime(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobApplication_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobApplication", field, false, false, errors.New("field of type Time does not have child fields")) -} - -func (ec *executionContext) _JobApplication_updatedAt(ctx context.Context, field graphql.CollectedField, obj *models.JobApplication) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobApplication_updatedAt(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.UpdatedAt, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v time.Time) graphql.Marshaler { - return ec.marshalNTime2timeᚐTime(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobApplication_updatedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobApplication", field, false, false, errors.New("field of type Time does not have child fields")) -} - -func (ec *executionContext) _JobApplication_jobTitle(ctx context.Context, field graphql.CollectedField, obj *models.JobApplication) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobApplication_jobTitle(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.JobTitle, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobApplication_jobTitle(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobApplication", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _JobApplication_company(ctx context.Context, field graphql.CollectedField, obj *models.JobApplication) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobApplication_company(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Company, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobApplication_company(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobApplication", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _JobApplication_location(ctx context.Context, field graphql.CollectedField, obj *models.JobApplication) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobApplication_location(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Location, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v *string) graphql.Marshaler { - return ec.marshalOString2ᚖstring(ctx, selections, v) - }, - true, - false, - ) -} -func (ec *executionContext) fieldContext_JobApplication_location(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobApplication", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _JobApplication_url(ctx context.Context, field graphql.CollectedField, obj *models.JobApplication) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobApplication_url(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.URL, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v *string) graphql.Marshaler { - return ec.marshalOString2ᚖstring(ctx, selections, v) - }, - true, - false, - ) -} -func (ec *executionContext) fieldContext_JobApplication_url(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobApplication", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _JobApplication_status(ctx context.Context, field graphql.CollectedField, obj *models.JobApplication) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobApplication_status(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Status, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNJobStatus2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobApplication_status(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobApplication", field, false, false, errors.New("field of type JobStatus does not have child fields")) -} - -func (ec *executionContext) _JobApplication_notes(ctx context.Context, field graphql.CollectedField, obj *models.JobApplication) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobApplication_notes(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Notes, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v *string) graphql.Marshaler { - return ec.marshalOString2ᚖstring(ctx, selections, v) - }, - true, - false, - ) -} -func (ec *executionContext) fieldContext_JobApplication_notes(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobApplication", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _JobApplication_appliedAt(ctx context.Context, field graphql.CollectedField, obj *models.JobApplication) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobApplication_appliedAt(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.AppliedAt, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v *time.Time) graphql.Marshaler { - return ec.marshalOTime2ᚖtimeᚐTime(ctx, selections, v) - }, - true, - false, - ) -} -func (ec *executionContext) fieldContext_JobApplication_appliedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobApplication", field, false, false, errors.New("field of type Time does not have child fields")) -} - -func (ec *executionContext) _JobApplication_description(ctx context.Context, field graphql.CollectedField, obj *models.JobApplication) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobApplication_description(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Description, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v *string) graphql.Marshaler { - return ec.marshalOString2ᚖstring(ctx, selections, v) - }, - true, - false, - ) -} -func (ec *executionContext) fieldContext_JobApplication_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobApplication", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _JobLead_id(ctx context.Context, field graphql.CollectedField, obj *models.JobLead) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobLead_id(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.ID, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v uint) graphql.Marshaler { - return ec.marshalNID2uint(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobLead_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobLead", field, false, false, errors.New("field of type ID does not have child fields")) -} - -func (ec *executionContext) _JobLead_createdAt(ctx context.Context, field graphql.CollectedField, obj *models.JobLead) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobLead_createdAt(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v time.Time) graphql.Marshaler { - return ec.marshalNTime2timeᚐTime(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobLead_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobLead", field, false, false, errors.New("field of type Time does not have child fields")) -} - -func (ec *executionContext) _JobLead_sourceKind(ctx context.Context, field graphql.CollectedField, obj *models.JobLead) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobLead_sourceKind(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.SourceKind, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobLead_sourceKind(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobLead", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _JobLead_jobTitle(ctx context.Context, field graphql.CollectedField, obj *models.JobLead) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobLead_jobTitle(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.JobTitle, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobLead_jobTitle(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobLead", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _JobLead_company(ctx context.Context, field graphql.CollectedField, obj *models.JobLead) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobLead_company(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Company, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobLead_company(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobLead", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _JobLead_location(ctx context.Context, field graphql.CollectedField, obj *models.JobLead) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobLead_location(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Location, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobLead_location(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobLead", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _JobLead_url(ctx context.Context, field graphql.CollectedField, obj *models.JobLead) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobLead_url(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.URL, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobLead_url(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobLead", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _JobLead_description(ctx context.Context, field graphql.CollectedField, obj *models.JobLead) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobLead_description(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Description, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobLead_description(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobLead", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _JobLead_postedAt(ctx context.Context, field graphql.CollectedField, obj *models.JobLead) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobLead_postedAt(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.PostedAt, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v *time.Time) graphql.Marshaler { - return ec.marshalOTime2ᚖtimeᚐTime(ctx, selections, v) - }, - true, - false, - ) -} -func (ec *executionContext) fieldContext_JobLead_postedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobLead", field, false, false, errors.New("field of type Time does not have child fields")) -} - -func (ec *executionContext) _JobLead_lastSeenAt(ctx context.Context, field graphql.CollectedField, obj *models.JobLead) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobLead_lastSeenAt(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.LastSeenAt, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v time.Time) graphql.Marshaler { - return ec.marshalNTime2timeᚐTime(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobLead_lastSeenAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobLead", field, false, false, errors.New("field of type Time does not have child fields")) -} - -func (ec *executionContext) _JobLead_matched(ctx context.Context, field graphql.CollectedField, obj *models.JobLead) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobLead_matched(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Matched, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v bool) graphql.Marshaler { - return ec.marshalNBoolean2bool(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobLead_matched(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobLead", field, false, false, errors.New("field of type Boolean does not have child fields")) -} - -func (ec *executionContext) _JobLead_state(ctx context.Context, field graphql.CollectedField, obj *models.JobLead) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobLead_state(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.State, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobLead_state(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobLead", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _JobLead_score(ctx context.Context, field graphql.CollectedField, obj *models.JobLead) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobLead_score(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Score, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v *int) graphql.Marshaler { - return ec.marshalOInt2ᚖint(ctx, selections, v) - }, - true, - false, - ) -} -func (ec *executionContext) fieldContext_JobLead_score(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobLead", field, false, false, errors.New("field of type Int does not have child fields")) -} - -func (ec *executionContext) _JobLead_scoreReasons(ctx context.Context, field graphql.CollectedField, obj *models.JobLead) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobLead_scoreReasons(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.ScoreReasons, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v *string) graphql.Marshaler { - return ec.marshalOString2ᚖstring(ctx, selections, v) - }, - true, - false, - ) -} -func (ec *executionContext) fieldContext_JobLead_scoreReasons(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobLead", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _JobLead_scoredAt(ctx context.Context, field graphql.CollectedField, obj *models.JobLead) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobLead_scoredAt(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.ScoredAt, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v *time.Time) graphql.Marshaler { - return ec.marshalOTime2ᚖtimeᚐTime(ctx, selections, v) - }, - true, - false, - ) -} -func (ec *executionContext) fieldContext_JobLead_scoredAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobLead", field, false, false, errors.New("field of type Time does not have child fields")) -} - -func (ec *executionContext) _JobLead_jobAppId(ctx context.Context, field graphql.CollectedField, obj *models.JobLead) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobLead_jobAppId(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.JobAppID, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v *uint) graphql.Marshaler { - return ec.marshalOID2ᚖuint(ctx, selections, v) - }, - true, - false, - ) -} -func (ec *executionContext) fieldContext_JobLead_jobAppId(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobLead", field, false, false, errors.New("field of type ID does not have child fields")) -} - -func (ec *executionContext) _JobLeadSyncStatus_running(ctx context.Context, field graphql.CollectedField, obj *model.JobLeadSyncStatus) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobLeadSyncStatus_running(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Running, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v bool) graphql.Marshaler { - return ec.marshalNBoolean2bool(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobLeadSyncStatus_running(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobLeadSyncStatus", field, false, false, errors.New("field of type Boolean does not have child fields")) -} - -func (ec *executionContext) _JobLeadSyncStatus_lastRunAt(ctx context.Context, field graphql.CollectedField, obj *model.JobLeadSyncStatus) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobLeadSyncStatus_lastRunAt(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.LastRunAt, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v *time.Time) graphql.Marshaler { - return ec.marshalOTime2ᚖtimeᚐTime(ctx, selections, v) - }, - true, - false, - ) -} -func (ec *executionContext) fieldContext_JobLeadSyncStatus_lastRunAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobLeadSyncStatus", field, false, false, errors.New("field of type Time does not have child fields")) -} - -func (ec *executionContext) _JobLeadSyncStatus_lastError(ctx context.Context, field graphql.CollectedField, obj *model.JobLeadSyncStatus) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobLeadSyncStatus_lastError(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.LastError, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobLeadSyncStatus_lastError(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobLeadSyncStatus", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _JobSearchProfile_updatedAt(ctx context.Context, field graphql.CollectedField, obj *models.JobSearchProfile) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobSearchProfile_updatedAt(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.UpdatedAt, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v time.Time) graphql.Marshaler { - return ec.marshalNTime2timeᚐTime(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobSearchProfile_updatedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobSearchProfile", field, false, false, errors.New("field of type Time does not have child fields")) -} - -func (ec *executionContext) _JobSearchProfile_profile(ctx context.Context, field graphql.CollectedField, obj *models.JobSearchProfile) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobSearchProfile_profile(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Profile, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobSearchProfile_profile(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobSearchProfile", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _JobSearchProfile_includeKeywords(ctx context.Context, field graphql.CollectedField, obj *models.JobSearchProfile) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobSearchProfile_includeKeywords(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.IncludeKeywords, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobSearchProfile_includeKeywords(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobSearchProfile", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _JobSearchProfile_excludeKeywords(ctx context.Context, field graphql.CollectedField, obj *models.JobSearchProfile) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobSearchProfile_excludeKeywords(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.ExcludeKeywords, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobSearchProfile_excludeKeywords(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobSearchProfile", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _JobSearchProfile_locations(ctx context.Context, field graphql.CollectedField, obj *models.JobSearchProfile) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobSearchProfile_locations(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Locations, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobSearchProfile_locations(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobSearchProfile", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _JobSearchProfile_minScore(ctx context.Context, field graphql.CollectedField, obj *models.JobSearchProfile) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobSearchProfile_minScore(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.MinScore, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v int) graphql.Marshaler { - return ec.marshalNInt2int(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobSearchProfile_minScore(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobSearchProfile", field, false, false, errors.New("field of type Int does not have child fields")) -} - -func (ec *executionContext) _JobSource_id(ctx context.Context, field graphql.CollectedField, obj *models.JobSource) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobSource_id(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.ID, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v uint) graphql.Marshaler { - return ec.marshalNID2uint(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobSource_id(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobSource", field, false, false, errors.New("field of type ID does not have child fields")) -} - -func (ec *executionContext) _JobSource_createdAt(ctx context.Context, field graphql.CollectedField, obj *models.JobSource) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobSource_createdAt(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.CreatedAt, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v time.Time) graphql.Marshaler { - return ec.marshalNTime2timeᚐTime(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobSource_createdAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobSource", field, false, false, errors.New("field of type Time does not have child fields")) -} - -func (ec *executionContext) _JobSource_updatedAt(ctx context.Context, field graphql.CollectedField, obj *models.JobSource) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobSource_updatedAt(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.UpdatedAt, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v time.Time) graphql.Marshaler { - return ec.marshalNTime2timeᚐTime(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobSource_updatedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobSource", field, false, false, errors.New("field of type Time does not have child fields")) -} - -func (ec *executionContext) _JobSource_kind(ctx context.Context, field graphql.CollectedField, obj *models.JobSource) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobSource_kind(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Kind, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobSource_kind(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobSource", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _JobSource_label(ctx context.Context, field graphql.CollectedField, obj *models.JobSource) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobSource_label(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Label, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobSource_label(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobSource", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _JobSource_token(ctx context.Context, field graphql.CollectedField, obj *models.JobSource) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobSource_token(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Token, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobSource_token(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobSource", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _JobSource_query(ctx context.Context, field graphql.CollectedField, obj *models.JobSource) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobSource_query(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Query, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobSource_query(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobSource", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _JobSource_location(ctx context.Context, field graphql.CollectedField, obj *models.JobSource) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobSource_location(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Location, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobSource_location(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobSource", field, false, false, errors.New("field of type String does not have child fields")) -} - -func (ec *executionContext) _JobSource_enabled(ctx context.Context, field graphql.CollectedField, obj *models.JobSource) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobSource_enabled(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.Enabled, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v bool) graphql.Marshaler { - return ec.marshalNBoolean2bool(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobSource_enabled(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobSource", field, false, false, errors.New("field of type Boolean does not have child fields")) -} - -func (ec *executionContext) _JobSource_lastFetchedAt(ctx context.Context, field graphql.CollectedField, obj *models.JobSource) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobSource_lastFetchedAt(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.LastFetchedAt, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v *time.Time) graphql.Marshaler { - return ec.marshalOTime2ᚖtimeᚐTime(ctx, selections, v) - }, - true, - false, - ) -} -func (ec *executionContext) fieldContext_JobSource_lastFetchedAt(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobSource", field, false, false, errors.New("field of type Time does not have child fields")) -} - -func (ec *executionContext) _JobSource_lastCount(ctx context.Context, field graphql.CollectedField, obj *models.JobSource) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobSource_lastCount(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.LastCount, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v int) graphql.Marshaler { - return ec.marshalNInt2int(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobSource_lastCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobSource", field, false, false, errors.New("field of type Int does not have child fields")) -} - -func (ec *executionContext) _JobSource_lastError(ctx context.Context, field graphql.CollectedField, obj *models.JobSource) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_JobSource_lastError(ctx, field) - }, - func(ctx context.Context) (any, error) { - return obj.LastError, nil - }, - nil, - func(ctx context.Context, selections ast.SelectionSet, v string) graphql.Marshaler { - return ec.marshalNString2string(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_JobSource_lastError(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("JobSource", field, false, false, errors.New("field of type String does not have child fields")) -} - func (ec *executionContext) _Message_id(ctx context.Context, field graphql.CollectedField, obj *models.Message) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, @@ -5274,855 +2915,6 @@ func (ec *executionContext) fieldContext_Mutation_createFavorite(ctx context.Con return fc, nil } -func (ec *executionContext) _Mutation_createJobAppReference(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Mutation_createJobAppReference(ctx, field) - }, - func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.Resolvers.Mutation().CreateJobAppReference(ctx, fc.Args["input"].(model.CreateJobAppReferenceInput)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - if ec.Directives.Admin == nil { - var zeroVal *models.JobAppReference - return zeroVal, errors.New("directive admin is not implemented") - } - return ec.Directives.Admin(ctx, nil, directive0) - } - - next = directive1 - return next - }, - func(ctx context.Context, selections ast.SelectionSet, v *models.JobAppReference) graphql.Marshaler { - return ec.marshalNJobAppReference2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobAppReference(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_Mutation_createJobAppReference(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.childFields_JobAppReference(ctx, field) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createJobAppReference_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Mutation_updateJobAppReference(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Mutation_updateJobAppReference(ctx, field) - }, - func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.Resolvers.Mutation().UpdateJobAppReference(ctx, fc.Args["id"].(int), fc.Args["input"].(model.UpdateJobAppReferenceInput)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - if ec.Directives.Admin == nil { - var zeroVal *models.JobAppReference - return zeroVal, errors.New("directive admin is not implemented") - } - return ec.Directives.Admin(ctx, nil, directive0) - } - - next = directive1 - return next - }, - func(ctx context.Context, selections ast.SelectionSet, v *models.JobAppReference) graphql.Marshaler { - return ec.marshalNJobAppReference2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobAppReference(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_Mutation_updateJobAppReference(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.childFields_JobAppReference(ctx, field) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateJobAppReference_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Mutation_deleteJobAppReference(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Mutation_deleteJobAppReference(ctx, field) - }, - func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.Resolvers.Mutation().DeleteJobAppReference(ctx, fc.Args["id"].(int)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - if ec.Directives.Admin == nil { - var zeroVal bool - return zeroVal, errors.New("directive admin is not implemented") - } - return ec.Directives.Admin(ctx, nil, directive0) - } - - next = directive1 - return next - }, - func(ctx context.Context, selections ast.SelectionSet, v bool) graphql.Marshaler { - return ec.marshalNBoolean2bool(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_Mutation_deleteJobAppReference(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_deleteJobAppReference_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Mutation_createJobApplication(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Mutation_createJobApplication(ctx, field) - }, - func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.Resolvers.Mutation().CreateJobApplication(ctx, fc.Args["input"].(model.CreateJobApplicationInput)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - if ec.Directives.Admin == nil { - var zeroVal *models.JobApplication - return zeroVal, errors.New("directive admin is not implemented") - } - return ec.Directives.Admin(ctx, nil, directive0) - } - - next = directive1 - return next - }, - func(ctx context.Context, selections ast.SelectionSet, v *models.JobApplication) graphql.Marshaler { - return ec.marshalNJobApplication2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobApplication(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_Mutation_createJobApplication(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.childFields_JobApplication(ctx, field) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createJobApplication_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Mutation_updateJobApplication(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Mutation_updateJobApplication(ctx, field) - }, - func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.Resolvers.Mutation().UpdateJobApplication(ctx, fc.Args["id"].(int), fc.Args["input"].(model.UpdateJobApplicationInput)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - if ec.Directives.Admin == nil { - var zeroVal *models.JobApplication - return zeroVal, errors.New("directive admin is not implemented") - } - return ec.Directives.Admin(ctx, nil, directive0) - } - - next = directive1 - return next - }, - func(ctx context.Context, selections ast.SelectionSet, v *models.JobApplication) graphql.Marshaler { - return ec.marshalNJobApplication2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobApplication(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_Mutation_updateJobApplication(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.childFields_JobApplication(ctx, field) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateJobApplication_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Mutation_deleteJobApplication(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Mutation_deleteJobApplication(ctx, field) - }, - func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.Resolvers.Mutation().DeleteJobApplication(ctx, fc.Args["id"].(int)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - if ec.Directives.Admin == nil { - var zeroVal bool - return zeroVal, errors.New("directive admin is not implemented") - } - return ec.Directives.Admin(ctx, nil, directive0) - } - - next = directive1 - return next - }, - func(ctx context.Context, selections ast.SelectionSet, v bool) graphql.Marshaler { - return ec.marshalNBoolean2bool(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_Mutation_deleteJobApplication(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_deleteJobApplication_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Mutation_createJobSource(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Mutation_createJobSource(ctx, field) - }, - func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.Resolvers.Mutation().CreateJobSource(ctx, fc.Args["input"].(model.CreateJobSourceInput)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - if ec.Directives.Admin == nil { - var zeroVal *models.JobSource - return zeroVal, errors.New("directive admin is not implemented") - } - return ec.Directives.Admin(ctx, nil, directive0) - } - - next = directive1 - return next - }, - func(ctx context.Context, selections ast.SelectionSet, v *models.JobSource) graphql.Marshaler { - return ec.marshalNJobSource2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobSource(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_Mutation_createJobSource(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.childFields_JobSource(ctx, field) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_createJobSource_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Mutation_updateJobSource(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Mutation_updateJobSource(ctx, field) - }, - func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.Resolvers.Mutation().UpdateJobSource(ctx, fc.Args["id"].(int), fc.Args["input"].(model.UpdateJobSourceInput)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - if ec.Directives.Admin == nil { - var zeroVal *models.JobSource - return zeroVal, errors.New("directive admin is not implemented") - } - return ec.Directives.Admin(ctx, nil, directive0) - } - - next = directive1 - return next - }, - func(ctx context.Context, selections ast.SelectionSet, v *models.JobSource) graphql.Marshaler { - return ec.marshalNJobSource2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobSource(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_Mutation_updateJobSource(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.childFields_JobSource(ctx, field) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateJobSource_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Mutation_deleteJobSource(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Mutation_deleteJobSource(ctx, field) - }, - func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.Resolvers.Mutation().DeleteJobSource(ctx, fc.Args["id"].(int)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - if ec.Directives.Admin == nil { - var zeroVal bool - return zeroVal, errors.New("directive admin is not implemented") - } - return ec.Directives.Admin(ctx, nil, directive0) - } - - next = directive1 - return next - }, - func(ctx context.Context, selections ast.SelectionSet, v bool) graphql.Marshaler { - return ec.marshalNBoolean2bool(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_Mutation_deleteJobSource(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type Boolean does not have child fields") - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_deleteJobSource_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Mutation_dismissJobLead(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Mutation_dismissJobLead(ctx, field) - }, - func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.Resolvers.Mutation().DismissJobLead(ctx, fc.Args["id"].(int)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - if ec.Directives.Admin == nil { - var zeroVal *models.JobLead - return zeroVal, errors.New("directive admin is not implemented") - } - return ec.Directives.Admin(ctx, nil, directive0) - } - - next = directive1 - return next - }, - func(ctx context.Context, selections ast.SelectionSet, v *models.JobLead) graphql.Marshaler { - return ec.marshalNJobLead2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobLead(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_Mutation_dismissJobLead(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.childFields_JobLead(ctx, field) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_dismissJobLead_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Mutation_restoreJobLead(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Mutation_restoreJobLead(ctx, field) - }, - func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.Resolvers.Mutation().RestoreJobLead(ctx, fc.Args["id"].(int)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - if ec.Directives.Admin == nil { - var zeroVal *models.JobLead - return zeroVal, errors.New("directive admin is not implemented") - } - return ec.Directives.Admin(ctx, nil, directive0) - } - - next = directive1 - return next - }, - func(ctx context.Context, selections ast.SelectionSet, v *models.JobLead) graphql.Marshaler { - return ec.marshalNJobLead2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobLead(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_Mutation_restoreJobLead(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.childFields_JobLead(ctx, field) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_restoreJobLead_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Mutation_promoteJobLead(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Mutation_promoteJobLead(ctx, field) - }, - func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.Resolvers.Mutation().PromoteJobLead(ctx, fc.Args["id"].(int)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - if ec.Directives.Admin == nil { - var zeroVal *models.JobLead - return zeroVal, errors.New("directive admin is not implemented") - } - return ec.Directives.Admin(ctx, nil, directive0) - } - - next = directive1 - return next - }, - func(ctx context.Context, selections ast.SelectionSet, v *models.JobLead) graphql.Marshaler { - return ec.marshalNJobLead2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobLead(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_Mutation_promoteJobLead(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.childFields_JobLead(ctx, field) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_promoteJobLead_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Mutation_updateJobSearchProfile(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Mutation_updateJobSearchProfile(ctx, field) - }, - func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.Resolvers.Mutation().UpdateJobSearchProfile(ctx, fc.Args["input"].(model.UpdateJobSearchProfileInput)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - if ec.Directives.Admin == nil { - var zeroVal *models.JobSearchProfile - return zeroVal, errors.New("directive admin is not implemented") - } - return ec.Directives.Admin(ctx, nil, directive0) - } - - next = directive1 - return next - }, - func(ctx context.Context, selections ast.SelectionSet, v *models.JobSearchProfile) graphql.Marshaler { - return ec.marshalNJobSearchProfile2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobSearchProfile(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_Mutation_updateJobSearchProfile(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Mutation", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.childFields_JobSearchProfile(ctx, field) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_updateJobSearchProfile_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Mutation_runJobLeadSync(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Mutation_runJobLeadSync(ctx, field) - }, - func(ctx context.Context) (any, error) { - return ec.Resolvers.Mutation().RunJobLeadSync(ctx) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - if ec.Directives.Admin == nil { - var zeroVal bool - return zeroVal, errors.New("directive admin is not implemented") - } - return ec.Directives.Admin(ctx, nil, directive0) - } - - next = directive1 - return next - }, - func(ctx context.Context, selections ast.SelectionSet, v bool) graphql.Marshaler { - return ec.marshalNBoolean2bool(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_Mutation_runJobLeadSync(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Mutation", field, true, true, errors.New("field of type Boolean does not have child fields")) -} - -func (ec *executionContext) _Mutation_scoreJobLeads(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Mutation_scoreJobLeads(ctx, field) - }, - func(ctx context.Context) (any, error) { - return ec.Resolvers.Mutation().ScoreJobLeads(ctx) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - if ec.Directives.Admin == nil { - var zeroVal bool - return zeroVal, errors.New("directive admin is not implemented") - } - return ec.Directives.Admin(ctx, nil, directive0) - } - - next = directive1 - return next - }, - func(ctx context.Context, selections ast.SelectionSet, v bool) graphql.Marshaler { - return ec.marshalNBoolean2bool(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_Mutation_scoreJobLeads(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Mutation", field, true, true, errors.New("field of type Boolean does not have child fields")) -} - -func (ec *executionContext) _Mutation_rescoreJobLeads(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Mutation_rescoreJobLeads(ctx, field) - }, - func(ctx context.Context) (any, error) { - return ec.Resolvers.Mutation().RescoreJobLeads(ctx) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - if ec.Directives.Admin == nil { - var zeroVal bool - return zeroVal, errors.New("directive admin is not implemented") - } - return ec.Directives.Admin(ctx, nil, directive0) - } - - next = directive1 - return next - }, - func(ctx context.Context, selections ast.SelectionSet, v bool) graphql.Marshaler { - return ec.marshalNBoolean2bool(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_Mutation_rescoreJobLeads(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - return graphql.NewScalarFieldContext("Mutation", field, true, true, errors.New("field of type Boolean does not have child fields")) -} - func (ec *executionContext) _Mutation_createPlace(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, @@ -7196,402 +3988,6 @@ func (ec *executionContext) fieldContext_Query_giteaFeed(_ context.Context, fiel return fc, nil } -func (ec *executionContext) _Query_jobAppReferences(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Query_jobAppReferences(ctx, field) - }, - func(ctx context.Context) (any, error) { - return ec.Resolvers.Query().JobAppReferences(ctx) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - if ec.Directives.Admin == nil { - var zeroVal []*models.JobAppReference - return zeroVal, errors.New("directive admin is not implemented") - } - return ec.Directives.Admin(ctx, nil, directive0) - } - - next = directive1 - return next - }, - func(ctx context.Context, selections ast.SelectionSet, v []*models.JobAppReference) graphql.Marshaler { - return ec.marshalNJobAppReference2ᚕᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobAppReferenceᚄ(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_Query_jobAppReferences(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.childFields_JobAppReference(ctx, field) - }, - } - return fc, nil -} - -func (ec *executionContext) _Query_jobApplications(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Query_jobApplications(ctx, field) - }, - func(ctx context.Context) (any, error) { - return ec.Resolvers.Query().JobApplications(ctx) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - if ec.Directives.Admin == nil { - var zeroVal []*models.JobApplication - return zeroVal, errors.New("directive admin is not implemented") - } - return ec.Directives.Admin(ctx, nil, directive0) - } - - next = directive1 - return next - }, - func(ctx context.Context, selections ast.SelectionSet, v []*models.JobApplication) graphql.Marshaler { - return ec.marshalNJobApplication2ᚕᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobApplicationᚄ(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_Query_jobApplications(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.childFields_JobApplication(ctx, field) - }, - } - return fc, nil -} - -func (ec *executionContext) _Query_jobApplication(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Query_jobApplication(ctx, field) - }, - func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.Resolvers.Query().JobApplication(ctx, fc.Args["id"].(int)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - if ec.Directives.Admin == nil { - var zeroVal *models.JobApplication - return zeroVal, errors.New("directive admin is not implemented") - } - return ec.Directives.Admin(ctx, nil, directive0) - } - - next = directive1 - return next - }, - func(ctx context.Context, selections ast.SelectionSet, v *models.JobApplication) graphql.Marshaler { - return ec.marshalOJobApplication2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobApplication(ctx, selections, v) - }, - true, - false, - ) -} -func (ec *executionContext) fieldContext_Query_jobApplication(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.childFields_JobApplication(ctx, field) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_jobApplication_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Query_jobSources(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Query_jobSources(ctx, field) - }, - func(ctx context.Context) (any, error) { - return ec.Resolvers.Query().JobSources(ctx) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - if ec.Directives.Admin == nil { - var zeroVal []*models.JobSource - return zeroVal, errors.New("directive admin is not implemented") - } - return ec.Directives.Admin(ctx, nil, directive0) - } - - next = directive1 - return next - }, - func(ctx context.Context, selections ast.SelectionSet, v []*models.JobSource) graphql.Marshaler { - return ec.marshalNJobSource2ᚕᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobSourceᚄ(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_Query_jobSources(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.childFields_JobSource(ctx, field) - }, - } - return fc, nil -} - -func (ec *executionContext) _Query_jobLeads(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Query_jobLeads(ctx, field) - }, - func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.Resolvers.Query().JobLeads(ctx, fc.Args["state"].(*string), fc.Args["includeUnmatched"].(*bool)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - if ec.Directives.Admin == nil { - var zeroVal []*models.JobLead - return zeroVal, errors.New("directive admin is not implemented") - } - return ec.Directives.Admin(ctx, nil, directive0) - } - - next = directive1 - return next - }, - func(ctx context.Context, selections ast.SelectionSet, v []*models.JobLead) graphql.Marshaler { - return ec.marshalNJobLead2ᚕᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobLeadᚄ(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_Query_jobLeads(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.childFields_JobLead(ctx, field) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_jobLeads_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Query_jobLead(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Query_jobLead(ctx, field) - }, - func(ctx context.Context) (any, error) { - fc := graphql.GetFieldContext(ctx) - return ec.Resolvers.Query().JobLead(ctx, fc.Args["id"].(int)) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - if ec.Directives.Admin == nil { - var zeroVal *models.JobLead - return zeroVal, errors.New("directive admin is not implemented") - } - return ec.Directives.Admin(ctx, nil, directive0) - } - - next = directive1 - return next - }, - func(ctx context.Context, selections ast.SelectionSet, v *models.JobLead) graphql.Marshaler { - return ec.marshalOJobLead2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobLead(ctx, selections, v) - }, - true, - false, - ) -} -func (ec *executionContext) fieldContext_Query_jobLead(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.childFields_JobLead(ctx, field) - }, - } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Query_jobLead_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return fc, err - } - return fc, nil -} - -func (ec *executionContext) _Query_jobSearchProfile(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Query_jobSearchProfile(ctx, field) - }, - func(ctx context.Context) (any, error) { - return ec.Resolvers.Query().JobSearchProfile(ctx) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - if ec.Directives.Admin == nil { - var zeroVal *models.JobSearchProfile - return zeroVal, errors.New("directive admin is not implemented") - } - return ec.Directives.Admin(ctx, nil, directive0) - } - - next = directive1 - return next - }, - func(ctx context.Context, selections ast.SelectionSet, v *models.JobSearchProfile) graphql.Marshaler { - return ec.marshalNJobSearchProfile2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobSearchProfile(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_Query_jobSearchProfile(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.childFields_JobSearchProfile(ctx, field) - }, - } - return fc, nil -} - -func (ec *executionContext) _Query_jobLeadSyncStatus(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - return graphql.ResolveField( - ctx, - ec.OperationContext, - field, - func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.fieldContext_Query_jobLeadSyncStatus(ctx, field) - }, - func(ctx context.Context) (any, error) { - return ec.Resolvers.Query().JobLeadSyncStatus(ctx) - }, - func(ctx context.Context, next graphql.Resolver) graphql.Resolver { - directive0 := next - - directive1 := func(ctx context.Context) (any, error) { - if ec.Directives.Admin == nil { - var zeroVal *model.JobLeadSyncStatus - return zeroVal, errors.New("directive admin is not implemented") - } - return ec.Directives.Admin(ctx, nil, directive0) - } - - next = directive1 - return next - }, - func(ctx context.Context, selections ast.SelectionSet, v *model.JobLeadSyncStatus) graphql.Marshaler { - return ec.marshalNJobLeadSyncStatus2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋgraphᚋmodelᚐJobLeadSyncStatus(ctx, selections, v) - }, - true, - true, - ) -} -func (ec *executionContext) fieldContext_Query_jobLeadSyncStatus(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Query", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return ec.childFields_JobLeadSyncStatus(ctx, field) - }, - } - return fc, nil -} - func (ec *executionContext) _Query_messages(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { return graphql.ResolveField( ctx, @@ -10009,201 +6405,6 @@ func (ec *executionContext) unmarshalInputCreateFavoriteInput(ctx context.Contex return it, nil } -func (ec *executionContext) unmarshalInputCreateJobAppReferenceInput(ctx context.Context, obj any) (model.CreateJobAppReferenceInput, error) { - var it model.CreateJobAppReferenceInput - if obj == nil { - return it, nil - } - - asMap := map[string]any{} - for k, v := range obj.(map[string]any) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"category", "label", "value", "sortOrder"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "category": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("category")) - data, err := ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - it.Category = data - case "label": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("label")) - data, err := ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - it.Label = data - case "value": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("value")) - data, err := ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - it.Value = data - case "sortOrder": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sortOrder")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.SortOrder = data - } - } - return it, nil -} - -func (ec *executionContext) unmarshalInputCreateJobApplicationInput(ctx context.Context, obj any) (model.CreateJobApplicationInput, error) { - var it model.CreateJobApplicationInput - if obj == nil { - return it, nil - } - - asMap := map[string]any{} - for k, v := range obj.(map[string]any) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"jobTitle", "company", "location", "url", "status", "notes", "appliedAt", "description"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "jobTitle": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("jobTitle")) - data, err := ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - it.JobTitle = data - case "company": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("company")) - data, err := ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - it.Company = data - case "location": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("location")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Location = data - case "url": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("url")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.URL = data - case "status": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) - data, err := ec.unmarshalNJobStatus2string(ctx, v) - if err != nil { - return it, err - } - it.Status = data - case "notes": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("notes")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Notes = data - case "appliedAt": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("appliedAt")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.AppliedAt = data - case "description": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("description")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Description = data - } - } - return it, nil -} - -func (ec *executionContext) unmarshalInputCreateJobSourceInput(ctx context.Context, obj any) (model.CreateJobSourceInput, error) { - var it model.CreateJobSourceInput - if obj == nil { - return it, nil - } - - asMap := map[string]any{} - for k, v := range obj.(map[string]any) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"kind", "label", "token", "query", "location", "enabled"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "kind": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("kind")) - data, err := ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - it.Kind = data - case "label": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("label")) - data, err := ec.unmarshalNString2string(ctx, v) - if err != nil { - return it, err - } - it.Label = data - case "token": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("token")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Token = data - case "query": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("query")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Query = data - case "location": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("location")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Location = data - case "enabled": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("enabled")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.Enabled = data - } - } - return it, nil -} - func (ec *executionContext) unmarshalInputCreatePlaceInput(ctx context.Context, obj any) (model.CreatePlaceInput, error) { var it model.CreatePlaceInput if obj == nil { @@ -10394,259 +6595,6 @@ func (ec *executionContext) unmarshalInputLoginInput(ctx context.Context, obj an return it, nil } -func (ec *executionContext) unmarshalInputUpdateJobAppReferenceInput(ctx context.Context, obj any) (model.UpdateJobAppReferenceInput, error) { - var it model.UpdateJobAppReferenceInput - if obj == nil { - return it, nil - } - - asMap := map[string]any{} - for k, v := range obj.(map[string]any) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"category", "label", "value", "sortOrder"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "category": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("category")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Category = data - case "label": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("label")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Label = data - case "value": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("value")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Value = data - case "sortOrder": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("sortOrder")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.SortOrder = data - } - } - return it, nil -} - -func (ec *executionContext) unmarshalInputUpdateJobApplicationInput(ctx context.Context, obj any) (model.UpdateJobApplicationInput, error) { - var it model.UpdateJobApplicationInput - if obj == nil { - return it, nil - } - - asMap := map[string]any{} - for k, v := range obj.(map[string]any) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"jobTitle", "company", "location", "url", "status", "notes", "appliedAt", "description"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "jobTitle": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("jobTitle")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.JobTitle = data - case "company": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("company")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Company = data - case "location": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("location")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Location = data - case "url": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("url")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.URL = data - case "status": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("status")) - data, err := ec.unmarshalOJobStatus2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Status = data - case "notes": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("notes")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Notes = data - case "appliedAt": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("appliedAt")) - data, err := ec.unmarshalOTime2ᚖtimeᚐTime(ctx, v) - if err != nil { - return it, err - } - it.AppliedAt = data - case "description": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("description")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Description = data - } - } - return it, nil -} - -func (ec *executionContext) unmarshalInputUpdateJobSearchProfileInput(ctx context.Context, obj any) (model.UpdateJobSearchProfileInput, error) { - var it model.UpdateJobSearchProfileInput - if obj == nil { - return it, nil - } - - asMap := map[string]any{} - for k, v := range obj.(map[string]any) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"profile", "includeKeywords", "excludeKeywords", "locations", "minScore"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "profile": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("profile")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Profile = data - case "includeKeywords": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeKeywords")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.IncludeKeywords = data - case "excludeKeywords": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("excludeKeywords")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.ExcludeKeywords = data - case "locations": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("locations")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Locations = data - case "minScore": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("minScore")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) - if err != nil { - return it, err - } - it.MinScore = data - } - } - return it, nil -} - -func (ec *executionContext) unmarshalInputUpdateJobSourceInput(ctx context.Context, obj any) (model.UpdateJobSourceInput, error) { - var it model.UpdateJobSourceInput - if obj == nil { - return it, nil - } - - asMap := map[string]any{} - for k, v := range obj.(map[string]any) { - asMap[k] = v - } - - fieldsInOrder := [...]string{"kind", "label", "token", "query", "location", "enabled"} - for _, k := range fieldsInOrder { - v, ok := asMap[k] - if !ok { - continue - } - switch k { - case "kind": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("kind")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Kind = data - case "label": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("label")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Label = data - case "token": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("token")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Token = data - case "query": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("query")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Query = data - case "location": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("location")) - data, err := ec.unmarshalOString2ᚖstring(ctx, v) - if err != nil { - return it, err - } - it.Location = data - case "enabled": - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("enabled")) - data, err := ec.unmarshalOBoolean2ᚖbool(ctx, v) - if err != nil { - return it, err - } - it.Enabled = data - } - } - return it, nil -} - func (ec *executionContext) unmarshalInputUpdatePlaceInput(ctx context.Context, obj any) (model.UpdatePlaceInput, error) { var it model.UpdatePlaceInput if obj == nil { @@ -11061,479 +7009,6 @@ func (ec *executionContext) _GiteaFeedItem(ctx context.Context, sel ast.Selectio return out } -var jobAppReferenceImplementors = []string{"JobAppReference"} - -func (ec *executionContext) _JobAppReference(ctx context.Context, sel ast.SelectionSet, obj *models.JobAppReference) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, jobAppReferenceImplementors) - - out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("JobAppReference") - case "id": - out.Values[i] = ec._JobAppReference_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "createdAt": - out.Values[i] = ec._JobAppReference_createdAt(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "updatedAt": - out.Values[i] = ec._JobAppReference_updatedAt(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "category": - out.Values[i] = ec._JobAppReference_category(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "label": - out.Values[i] = ec._JobAppReference_label(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "value": - out.Values[i] = ec._JobAppReference_value(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "sortOrder": - out.Values[i] = ec._JobAppReference_sortOrder(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) - - return out -} - -var jobApplicationImplementors = []string{"JobApplication"} - -func (ec *executionContext) _JobApplication(ctx context.Context, sel ast.SelectionSet, obj *models.JobApplication) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, jobApplicationImplementors) - - out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("JobApplication") - case "id": - out.Values[i] = ec._JobApplication_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "createdAt": - out.Values[i] = ec._JobApplication_createdAt(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "updatedAt": - out.Values[i] = ec._JobApplication_updatedAt(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "jobTitle": - out.Values[i] = ec._JobApplication_jobTitle(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "company": - out.Values[i] = ec._JobApplication_company(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "location": - out.Values[i] = ec._JobApplication_location(ctx, field, obj) - if out.Values[i] == graphql.RequiredNull { - out.Invalids++ - } - case "url": - out.Values[i] = ec._JobApplication_url(ctx, field, obj) - if out.Values[i] == graphql.RequiredNull { - out.Invalids++ - } - case "status": - out.Values[i] = ec._JobApplication_status(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "notes": - out.Values[i] = ec._JobApplication_notes(ctx, field, obj) - if out.Values[i] == graphql.RequiredNull { - out.Invalids++ - } - case "appliedAt": - out.Values[i] = ec._JobApplication_appliedAt(ctx, field, obj) - if out.Values[i] == graphql.RequiredNull { - out.Invalids++ - } - case "description": - out.Values[i] = ec._JobApplication_description(ctx, field, obj) - if out.Values[i] == graphql.RequiredNull { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) - - return out -} - -var jobLeadImplementors = []string{"JobLead"} - -func (ec *executionContext) _JobLead(ctx context.Context, sel ast.SelectionSet, obj *models.JobLead) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, jobLeadImplementors) - - out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("JobLead") - case "id": - out.Values[i] = ec._JobLead_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "createdAt": - out.Values[i] = ec._JobLead_createdAt(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "sourceKind": - out.Values[i] = ec._JobLead_sourceKind(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "jobTitle": - out.Values[i] = ec._JobLead_jobTitle(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "company": - out.Values[i] = ec._JobLead_company(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "location": - out.Values[i] = ec._JobLead_location(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "url": - out.Values[i] = ec._JobLead_url(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "description": - out.Values[i] = ec._JobLead_description(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "postedAt": - out.Values[i] = ec._JobLead_postedAt(ctx, field, obj) - if out.Values[i] == graphql.RequiredNull { - out.Invalids++ - } - case "lastSeenAt": - out.Values[i] = ec._JobLead_lastSeenAt(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "matched": - out.Values[i] = ec._JobLead_matched(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "state": - out.Values[i] = ec._JobLead_state(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "score": - out.Values[i] = ec._JobLead_score(ctx, field, obj) - if out.Values[i] == graphql.RequiredNull { - out.Invalids++ - } - case "scoreReasons": - out.Values[i] = ec._JobLead_scoreReasons(ctx, field, obj) - if out.Values[i] == graphql.RequiredNull { - out.Invalids++ - } - case "scoredAt": - out.Values[i] = ec._JobLead_scoredAt(ctx, field, obj) - if out.Values[i] == graphql.RequiredNull { - out.Invalids++ - } - case "jobAppId": - out.Values[i] = ec._JobLead_jobAppId(ctx, field, obj) - if out.Values[i] == graphql.RequiredNull { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) - - return out -} - -var jobLeadSyncStatusImplementors = []string{"JobLeadSyncStatus"} - -func (ec *executionContext) _JobLeadSyncStatus(ctx context.Context, sel ast.SelectionSet, obj *model.JobLeadSyncStatus) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, jobLeadSyncStatusImplementors) - - out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("JobLeadSyncStatus") - case "running": - out.Values[i] = ec._JobLeadSyncStatus_running(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "lastRunAt": - out.Values[i] = ec._JobLeadSyncStatus_lastRunAt(ctx, field, obj) - if out.Values[i] == graphql.RequiredNull { - out.Invalids++ - } - case "lastError": - out.Values[i] = ec._JobLeadSyncStatus_lastError(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) - - return out -} - -var jobSearchProfileImplementors = []string{"JobSearchProfile"} - -func (ec *executionContext) _JobSearchProfile(ctx context.Context, sel ast.SelectionSet, obj *models.JobSearchProfile) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, jobSearchProfileImplementors) - - out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("JobSearchProfile") - case "updatedAt": - out.Values[i] = ec._JobSearchProfile_updatedAt(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "profile": - out.Values[i] = ec._JobSearchProfile_profile(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "includeKeywords": - out.Values[i] = ec._JobSearchProfile_includeKeywords(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "excludeKeywords": - out.Values[i] = ec._JobSearchProfile_excludeKeywords(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "locations": - out.Values[i] = ec._JobSearchProfile_locations(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "minScore": - out.Values[i] = ec._JobSearchProfile_minScore(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) - - return out -} - -var jobSourceImplementors = []string{"JobSource"} - -func (ec *executionContext) _JobSource(ctx context.Context, sel ast.SelectionSet, obj *models.JobSource) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, jobSourceImplementors) - - out := graphql.NewFieldSet(fields) - deferredFieldSet := graphql.NewFieldSet(nil) - deferLabelToView := make(map[string]*graphql.FieldSetView) - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("JobSource") - case "id": - out.Values[i] = ec._JobSource_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "createdAt": - out.Values[i] = ec._JobSource_createdAt(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "updatedAt": - out.Values[i] = ec._JobSource_updatedAt(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "kind": - out.Values[i] = ec._JobSource_kind(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "label": - out.Values[i] = ec._JobSource_label(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "token": - out.Values[i] = ec._JobSource_token(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "query": - out.Values[i] = ec._JobSource_query(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "location": - out.Values[i] = ec._JobSource_location(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "enabled": - out.Values[i] = ec._JobSource_enabled(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "lastFetchedAt": - out.Values[i] = ec._JobSource_lastFetchedAt(ctx, field, obj) - if out.Values[i] == graphql.RequiredNull { - out.Invalids++ - } - case "lastCount": - out.Values[i] = ec._JobSource_lastCount(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "lastError": - out.Values[i] = ec._JobSource_lastError(ctx, field, obj) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch(ctx) - if out.Invalids > 0 { - return graphql.Null - } - - atomic.AddInt32(&ec.Deferred, int32(min(len(deferLabelToView), math.MaxInt32))) - - ec.ProcessDeferredGroup(graphql.DeferredGroup{ - Defers: deferLabelToView, - Path: graphql.GetPath(ctx), - FieldSet: deferredFieldSet, - Context: ctx, - }) - - return out -} - var messageImplementors = []string{"Message"} func (ec *executionContext) _Message(ctx context.Context, sel ast.SelectionSet, obj *models.Message) graphql.Marshaler { @@ -11699,118 +7174,6 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) if out.Values[i] == graphql.Null { out.Invalids++ } - case "createJobAppReference": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_createJobAppReference(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "updateJobAppReference": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_updateJobAppReference(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "deleteJobAppReference": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_deleteJobAppReference(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "createJobApplication": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_createJobApplication(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "updateJobApplication": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_updateJobApplication(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "deleteJobApplication": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_deleteJobApplication(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "createJobSource": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_createJobSource(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "updateJobSource": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_updateJobSource(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "deleteJobSource": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_deleteJobSource(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "dismissJobLead": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_dismissJobLead(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "restoreJobLead": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_restoreJobLead(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "promoteJobLead": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_promoteJobLead(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "updateJobSearchProfile": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_updateJobSearchProfile(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "runJobLeadSync": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_runJobLeadSync(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "scoreJobLeads": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_scoreJobLeads(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ - } - case "rescoreJobLeads": - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._Mutation_rescoreJobLeads(ctx, field) - }) - if out.Values[i] == graphql.Null { - out.Invalids++ - } case "createPlace": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_createPlace(ctx, field) @@ -12175,182 +7538,6 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "jobAppReferences": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_jobAppReferences(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "jobApplications": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_jobApplications(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "jobApplication": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_jobApplication(ctx, field) - if res == graphql.RequiredNull { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "jobSources": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_jobSources(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "jobLeads": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_jobLeads(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "jobLead": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_jobLead(ctx, field) - if res == graphql.RequiredNull { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "jobSearchProfile": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_jobSearchProfile(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) - case "jobLeadSyncStatus": - field := field - - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Query_jobLeadSyncStatus(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&fs.Invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, - func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - } - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "messages": field := field @@ -13660,21 +8847,6 @@ func (ec *executionContext) unmarshalNCreateFavoriteInput2adamᚑfrenchᚗcoᚗu return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) unmarshalNCreateJobAppReferenceInput2adamᚑfrenchᚗcoᚗukᚋbackendᚋgraphᚋmodelᚐCreateJobAppReferenceInput(ctx context.Context, v any) (model.CreateJobAppReferenceInput, error) { - res, err := ec.unmarshalInputCreateJobAppReferenceInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalNCreateJobApplicationInput2adamᚑfrenchᚗcoᚗukᚋbackendᚋgraphᚋmodelᚐCreateJobApplicationInput(ctx context.Context, v any) (model.CreateJobApplicationInput, error) { - res, err := ec.unmarshalInputCreateJobApplicationInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalNCreateJobSourceInput2adamᚑfrenchᚗcoᚗukᚋbackendᚋgraphᚋmodelᚐCreateJobSourceInput(ctx context.Context, v any) (model.CreateJobSourceInput, error) { - res, err := ec.unmarshalInputCreateJobSourceInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - func (ec *executionContext) unmarshalNCreatePlaceInput2adamᚑfrenchᚗcoᚗukᚋbackendᚋgraphᚋmodelᚐCreatePlaceInput(ctx context.Context, v any) (model.CreatePlaceInput, error) { res, err := ec.unmarshalInputCreatePlaceInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -13780,146 +8952,6 @@ func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.Selecti return res } -func (ec *executionContext) marshalNJobAppReference2ᚕᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobAppReferenceᚄ(ctx context.Context, sel ast.SelectionSet, v []*models.JobAppReference) graphql.Marshaler { - ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { - fc := graphql.GetFieldContext(ctx) - fc.Result = &v[i] - return ec.marshalNJobAppReference2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobAppReference(ctx, sel, v[i]) - }) - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalNJobAppReference2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobAppReference(ctx context.Context, sel ast.SelectionSet, v *models.JobAppReference) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._JobAppReference(ctx, sel, v) -} - -func (ec *executionContext) marshalNJobApplication2ᚕᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobApplicationᚄ(ctx context.Context, sel ast.SelectionSet, v []*models.JobApplication) graphql.Marshaler { - ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { - fc := graphql.GetFieldContext(ctx) - fc.Result = &v[i] - return ec.marshalNJobApplication2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobApplication(ctx, sel, v[i]) - }) - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalNJobApplication2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobApplication(ctx context.Context, sel ast.SelectionSet, v *models.JobApplication) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._JobApplication(ctx, sel, v) -} - -func (ec *executionContext) marshalNJobLead2ᚕᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobLeadᚄ(ctx context.Context, sel ast.SelectionSet, v []*models.JobLead) graphql.Marshaler { - ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { - fc := graphql.GetFieldContext(ctx) - fc.Result = &v[i] - return ec.marshalNJobLead2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobLead(ctx, sel, v[i]) - }) - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalNJobLead2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobLead(ctx context.Context, sel ast.SelectionSet, v *models.JobLead) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._JobLead(ctx, sel, v) -} - -func (ec *executionContext) marshalNJobLeadSyncStatus2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋgraphᚋmodelᚐJobLeadSyncStatus(ctx context.Context, sel ast.SelectionSet, v *model.JobLeadSyncStatus) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._JobLeadSyncStatus(ctx, sel, v) -} - -func (ec *executionContext) marshalNJobSearchProfile2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobSearchProfile(ctx context.Context, sel ast.SelectionSet, v *models.JobSearchProfile) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._JobSearchProfile(ctx, sel, v) -} - -func (ec *executionContext) marshalNJobSource2ᚕᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobSourceᚄ(ctx context.Context, sel ast.SelectionSet, v []*models.JobSource) graphql.Marshaler { - ret := graphql.MarshalSliceConcurrently(ctx, len(v), 0, false, func(ctx context.Context, i int) graphql.Marshaler { - fc := graphql.GetFieldContext(ctx) - fc.Result = &v[i] - return ec.marshalNJobSource2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobSource(ctx, sel, v[i]) - }) - - for _, e := range ret { - if e == graphql.Null { - return graphql.Null - } - } - - return ret -} - -func (ec *executionContext) marshalNJobSource2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobSource(ctx context.Context, sel ast.SelectionSet, v *models.JobSource) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } - return graphql.Null - } - return ec._JobSource(ctx, sel, v) -} - -func (ec *executionContext) unmarshalNJobStatus2string(ctx context.Context, v any) (string, error) { - res, err := services.UnmarshalJobStatus(v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalNJobStatus2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - _ = sel - res := services.MarshalJobStatus(v) - if res == graphql.Null { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - graphql.AddErrorf(ctx, "the requested element is null which the schema does not allow") - } - } - return res -} - func (ec *executionContext) unmarshalNLoginInput2adamᚑfrenchᚗcoᚗukᚋbackendᚋgraphᚋmodelᚐLoginInput(ctx context.Context, v any) (model.LoginInput, error) { res, err := ec.unmarshalInputLoginInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -14169,26 +9201,6 @@ func (ec *executionContext) marshalNTime2timeᚐTime(ctx context.Context, sel as return res } -func (ec *executionContext) unmarshalNUpdateJobAppReferenceInput2adamᚑfrenchᚗcoᚗukᚋbackendᚋgraphᚋmodelᚐUpdateJobAppReferenceInput(ctx context.Context, v any) (model.UpdateJobAppReferenceInput, error) { - res, err := ec.unmarshalInputUpdateJobAppReferenceInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalNUpdateJobApplicationInput2adamᚑfrenchᚗcoᚗukᚋbackendᚋgraphᚋmodelᚐUpdateJobApplicationInput(ctx context.Context, v any) (model.UpdateJobApplicationInput, error) { - res, err := ec.unmarshalInputUpdateJobApplicationInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalNUpdateJobSearchProfileInput2adamᚑfrenchᚗcoᚗukᚋbackendᚋgraphᚋmodelᚐUpdateJobSearchProfileInput(ctx context.Context, v any) (model.UpdateJobSearchProfileInput, error) { - res, err := ec.unmarshalInputUpdateJobSearchProfileInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalNUpdateJobSourceInput2adamᚑfrenchᚗcoᚗukᚋbackendᚋgraphᚋmodelᚐUpdateJobSourceInput(ctx context.Context, v any) (model.UpdateJobSourceInput, error) { - res, err := ec.unmarshalInputUpdateJobSourceInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - func (ec *executionContext) unmarshalNUpdatePlaceInput2adamᚑfrenchᚗcoᚗukᚋbackendᚋgraphᚋmodelᚐUpdatePlaceInput(ctx context.Context, v any) (model.UpdatePlaceInput, error) { res, err := ec.unmarshalInputUpdatePlaceInput(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -14402,24 +9414,6 @@ func (ec *executionContext) marshalOGiteaFeedItem2ᚖadamᚑfrenchᚗcoᚗukᚋb return ec._GiteaFeedItem(ctx, sel, v) } -func (ec *executionContext) unmarshalOID2ᚖuint(ctx context.Context, v any) (*uint, error) { - if v == nil { - return nil, nil - } - res, err := graphql.UnmarshalUintID(v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOID2ᚖuint(ctx context.Context, sel ast.SelectionSet, v *uint) graphql.Marshaler { - if v == nil { - return graphql.Null - } - _ = sel - _ = ctx - res := graphql.MarshalUintID(*v) - return res -} - func (ec *executionContext) unmarshalOInt2ᚖint(ctx context.Context, v any) (*int, error) { if v == nil { return nil, nil @@ -14438,38 +9432,6 @@ func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.Sele return res } -func (ec *executionContext) marshalOJobApplication2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobApplication(ctx context.Context, sel ast.SelectionSet, v *models.JobApplication) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._JobApplication(ctx, sel, v) -} - -func (ec *executionContext) marshalOJobLead2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐJobLead(ctx context.Context, sel ast.SelectionSet, v *models.JobLead) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._JobLead(ctx, sel, v) -} - -func (ec *executionContext) unmarshalOJobStatus2ᚖstring(ctx context.Context, v any) (*string, error) { - if v == nil { - return nil, nil - } - res, err := services.UnmarshalJobStatus(v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOJobStatus2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { - if v == nil { - return graphql.Null - } - _ = sel - _ = ctx - res := services.MarshalJobStatus(*v) - return res -} - func (ec *executionContext) marshalOPost2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐPost(ctx context.Context, sel ast.SelectionSet, v *models.Post) graphql.Marshaler { if v == nil { return graphql.Null @@ -14547,24 +9509,6 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as return res } -func (ec *executionContext) unmarshalOTime2ᚖtimeᚐTime(ctx context.Context, v any) (*time.Time, error) { - if v == nil { - return nil, nil - } - res, err := graphql.UnmarshalTime(v) - return &res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) marshalOTime2ᚖtimeᚐTime(ctx context.Context, sel ast.SelectionSet, v *time.Time) graphql.Marshaler { - if v == nil { - return graphql.Null - } - _ = sel - _ = ctx - res := graphql.MarshalTime(*v) - return res -} - func (ec *executionContext) marshalOUser2ᚖadamᚑfrenchᚗcoᚗukᚋbackendᚋmodelsᚐUser(ctx context.Context, sel ast.SelectionSet, v *models.User) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/backend/graph/job_app_reference.resolvers.go b/backend/graph/job_app_reference.resolvers.go deleted file mode 100644 index 4fe10d3..0000000 --- a/backend/graph/job_app_reference.resolvers.go +++ /dev/null @@ -1,78 +0,0 @@ -package graph - -// This file will be automatically regenerated based on the schema, any resolver -// implementations -// will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.95 - -import ( - "context" - - "adam-french.co.uk/backend/graph/model" - "adam-french.co.uk/backend/models" -) - -// CreateJobAppReference is the resolver for the createJobAppReference field. -func (r *mutationResolver) CreateJobAppReference(ctx context.Context, input model.CreateJobAppReferenceInput) (*models.JobAppReference, error) { - ref := models.JobAppReference{ - Category: input.Category, - Label: input.Label, - Value: input.Value, - } - if input.SortOrder != nil { - ref.SortOrder = *input.SortOrder - } - if err := r.Store.DB.Create(&ref).Error; err != nil { - return nil, err - } - return &ref, nil -} - -// UpdateJobAppReference is the resolver for the updateJobAppReference field. -func (r *mutationResolver) UpdateJobAppReference(ctx context.Context, id int, input model.UpdateJobAppReferenceInput) (*models.JobAppReference, error) { - var ref models.JobAppReference - if err := r.Store.DB.First(&ref, id).Error; err != nil { - return nil, err - } - if input.Category != nil { - ref.Category = *input.Category - } - if input.Label != nil { - ref.Label = *input.Label - } - if input.Value != nil { - ref.Value = *input.Value - } - if input.SortOrder != nil { - ref.SortOrder = *input.SortOrder - } - if err := r.Store.DB.Save(&ref).Error; err != nil { - return nil, err - } - return &ref, nil -} - -// DeleteJobAppReference is the resolver for the deleteJobAppReference field. -func (r *mutationResolver) DeleteJobAppReference(ctx context.Context, id int) (bool, error) { - // Loaded first so a missing id is an error rather than a `true` that - // deleted nothing; see DeleteJobApplication. - var ref models.JobAppReference - if err := r.Store.DB.First(&ref, id).Error; err != nil { - return false, err - } - if err := r.Store.DB.Delete(&ref).Error; err != nil { - return false, err - } - return true, nil -} - -// JobAppReferences is the resolver for the jobAppReferences field. -func (r *queryResolver) JobAppReferences(ctx context.Context) ([]*models.JobAppReference, error) { - var refs []*models.JobAppReference - // created_at is the final tie-break so entries sharing a sort_order (the - // default 0) keep a stable, insertion-ordered sequence. - if err := r.Store.DB.Order("category ASC, sort_order ASC, created_at ASC").Find(&refs).Error; err != nil { - return nil, err - } - return refs, nil -} diff --git a/backend/graph/job_application.resolvers.go b/backend/graph/job_application.resolvers.go deleted file mode 100644 index 5cc7491..0000000 --- a/backend/graph/job_application.resolvers.go +++ /dev/null @@ -1,140 +0,0 @@ -package graph - -// This file will be automatically regenerated based on the schema, any resolver -// implementations -// will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.95 - -import ( - "context" - "fmt" - "strings" - - "adam-french.co.uk/backend/graph/model" - "adam-french.co.uk/backend/models" -) - -// CreateJobApplication is the resolver for the createJobApplication field. -func (r *mutationResolver) CreateJobApplication(ctx context.Context, input model.CreateJobApplicationInput) (*models.JobApplication, error) { - // String! is non-null but not non-empty, and the columns are only - // `not null`, so "" stores happily and then never matches the email - // pipeline's LOWER(company) lookup — an orphan row no sync can advance. - jobTitle := strings.TrimSpace(input.JobTitle) - company := strings.TrimSpace(input.Company) - if jobTitle == "" || company == "" { - return nil, fmt.Errorf("jobTitle and company are required") - } - // input.Status is already one of the JobStatus values: the enum's - // unmarshaller (services.UnmarshalJobStatus) refused anything else before - // this resolver was reached, so it is stored as it came. - app := models.JobApplication{ - JobTitle: jobTitle, - Company: company, - Location: input.Location, - URL: input.URL, - Status: input.Status, - Notes: input.Notes, - AppliedAt: input.AppliedAt, - Description: input.Description, - } - if err := r.Store.DB.Create(&app).Error; err != nil { - return nil, err - } - return &app, nil -} - -// UpdateJobApplication is the resolver for the updateJobApplication field. -func (r *mutationResolver) UpdateJobApplication(ctx context.Context, id int, input model.UpdateJobApplicationInput) (*models.JobApplication, error) { - // Partial update: every input field is a pointer so that "not supplied" - // is distinguishable from "set to empty". A nil field is left untouched. - // An explicit "" on a nullable column does clear it — that is how the UI - // empties a wrong URL or stale notes — but the same value on a required - // column is rejected rather than blanking a live row. - var app models.JobApplication - if err := r.Store.DB.First(&app, id).Error; err != nil { - return nil, err - } - if input.JobTitle != nil { - if strings.TrimSpace(*input.JobTitle) == "" { - return nil, fmt.Errorf("jobTitle cannot be empty") - } - app.JobTitle = strings.TrimSpace(*input.JobTitle) - } - if input.Company != nil { - if strings.TrimSpace(*input.Company) == "" { - return nil, fmt.Errorf("company cannot be empty") - } - app.Company = strings.TrimSpace(*input.Company) - } - if input.Location != nil { - app.Location = input.Location - } - if input.URL != nil { - app.URL = input.URL - } - if input.Status != nil { - app.Status = *input.Status - } - if input.Notes != nil { - app.Notes = input.Notes - } - if input.AppliedAt != nil { - app.AppliedAt = input.AppliedAt - } - if input.Description != nil { - app.Description = input.Description - } - if err := r.Store.DB.Save(&app).Error; err != nil { - return nil, err - } - return &app, nil -} - -// DeleteJobApplication is the resolver for the deleteJobApplication field. -func (r *mutationResolver) DeleteJobApplication(ctx context.Context, id int) (bool, error) { - // Loaded first so a missing id is an error, as it is for the deletes that - // return the row (deletePost, deletePlace, deleteBookmark). Deleting by - // id alone reports success whether or not anything matched, which told - // the tracker a row was gone when it had never existed. The return type - // stays Boolean! for the front end's sake, so the only value is true. - // - // Soft delete: the row is kept, which is what lets the email pipeline see - // that an application was deleted and not re-create it. - var app models.JobApplication - if err := r.Store.DB.First(&app, id).Error; err != nil { - return false, err - } - if err := r.Store.DB.Delete(&app).Error; err != nil { - return false, err - } - return true, nil -} - -// JobApplications is the resolver for the jobApplications field. -func (r *queryResolver) JobApplications(ctx context.Context) ([]*models.JobApplication, error) { - // Admin-only even though it is a query (@admin in the schema): job - // applications are private. - // - // A row whose stored status is outside the JobStatus enum does not fail - // this list: services.MarshalJobStatus passes it through. - // - // Find can populate a slice of pointers directly, avoiding the - // copy-to-pointers loop the other list resolvers need. - var apps []*models.JobApplication - // id is the tie-break: one sync loop inserts several rows inside the same - // timestamp, and Postgres gives no stable order for equal sort keys, so - // without it the list can reshuffle between two identical page loads. - if err := r.Store.DB.Order("created_at desc, id desc").Find(&apps).Error; err != nil { - return nil, err - } - return apps, nil -} - -// JobApplication is the resolver for the jobApplication field. -func (r *queryResolver) JobApplication(ctx context.Context, id int) (*models.JobApplication, error) { - var app models.JobApplication - if err := r.Store.DB.First(&app, id).Error; err != nil { - return nil, err - } - return &app, nil -} diff --git a/backend/graph/job_lead.resolvers.go b/backend/graph/job_lead.resolvers.go deleted file mode 100644 index 2adba73..0000000 --- a/backend/graph/job_lead.resolvers.go +++ /dev/null @@ -1,220 +0,0 @@ -package graph - -// This file will be automatically regenerated based on the schema, any resolver -// implementations -// will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.95 - -import ( - "context" - "fmt" - "strings" - "time" - - "adam-french.co.uk/backend/graph/model" - "adam-french.co.uk/backend/models" - "adam-french.co.uk/backend/services" -) - -// CreateJobSource is the resolver for the createJobSource field. -func (r *mutationResolver) CreateJobSource(ctx context.Context, input model.CreateJobSourceInput) (*models.JobSource, error) { - src := models.JobSource{Kind: input.Kind, Label: input.Label, Enabled: true} - if input.Token != nil { - src.Token = *input.Token - } - if input.Query != nil { - src.Query = *input.Query - } - if input.Location != nil { - src.Location = *input.Location - } - if input.Enabled != nil { - src.Enabled = *input.Enabled - } - if err := services.ValidateJobSource(&src); err != nil { - return nil, err - } - if err := r.Store.DB.Create(&src).Error; err != nil { - return nil, err - } - return &src, nil -} - -// UpdateJobSource is the resolver for the updateJobSource field. -func (r *mutationResolver) UpdateJobSource(ctx context.Context, id int, input model.UpdateJobSourceInput) (*models.JobSource, error) { - // Partial update, as in UpdateJobApplication: a nil field is untouched. - // The merged row is validated as a whole, because whether a token or a - // query is required depends on the kind, which may itself be changing. - var src models.JobSource - if err := r.Store.DB.First(&src, id).Error; err != nil { - return nil, err - } - if input.Kind != nil { - src.Kind = *input.Kind - } - if input.Label != nil { - src.Label = *input.Label - } - if input.Token != nil { - src.Token = *input.Token - } - if input.Query != nil { - src.Query = *input.Query - } - if input.Location != nil { - src.Location = *input.Location - } - if input.Enabled != nil { - src.Enabled = *input.Enabled - } - if err := services.ValidateJobSource(&src); err != nil { - return nil, err - } - // Named columns rather than Save: the fetcher writes last_fetched_at, - // last_count and last_error on this row during a run, and saving the - // whole struct loaded above would put stale values back over them. - if err := r.Store.DB.Model(&src). - Select("Kind", "Label", "Token", "Query", "Location", "Enabled"). - Updates(&src).Error; err != nil { - return nil, err - } - return &src, nil -} - -// DeleteJobSource is the resolver for the deleteJobSource field. -func (r *mutationResolver) DeleteJobSource(ctx context.Context, id int) (bool, error) { - // Loaded first so a missing id is an error; see DeleteJobApplication. - // The source's leads are deliberately left alone: they are still real - // postings, and deleting them would let a re-added source file every one - // of them again, dismissed ones included. - var src models.JobSource - if err := r.Store.DB.First(&src, id).Error; err != nil { - return false, err - } - if err := r.Store.DB.Delete(&src).Error; err != nil { - return false, err - } - return true, nil -} - -// DismissJobLead is the resolver for the dismissJobLead field. -func (r *mutationResolver) DismissJobLead(ctx context.Context, id int) (*models.JobLead, error) { - return r.setLeadState(id, services.LeadNew, services.LeadDismissed) -} - -// RestoreJobLead is the resolver for the restoreJobLead field. -func (r *mutationResolver) RestoreJobLead(ctx context.Context, id int) (*models.JobLead, error) { - return r.setLeadState(id, services.LeadDismissed, services.LeadNew) -} - -// PromoteJobLead is the resolver for the promoteJobLead field. -func (r *mutationResolver) PromoteJobLead(ctx context.Context, id int) (*models.JobLead, error) { - return services.PromoteJobLead(r.Store.DB, uint(id), time.Now()) -} - -// UpdateJobSearchProfile is the resolver for the updateJobSearchProfile field. -func (r *mutationResolver) UpdateJobSearchProfile(ctx context.Context, input model.UpdateJobSearchProfileInput) (*models.JobSearchProfile, error) { - profile, err := services.LoadJobSearchProfile(r.Store.DB) - if err != nil { - return nil, err - } - if input.Profile != nil { - profile.Profile = *input.Profile - } - if input.IncludeKeywords != nil { - profile.IncludeKeywords = strings.TrimSpace(*input.IncludeKeywords) - } - if input.ExcludeKeywords != nil { - profile.ExcludeKeywords = strings.TrimSpace(*input.ExcludeKeywords) - } - if input.Locations != nil { - profile.Locations = strings.TrimSpace(*input.Locations) - } - if input.MinScore != nil { - profile.MinScore = *input.MinScore - } - if err := services.SaveJobSearchProfile(r.Store.DB, profile); err != nil { - return nil, err - } - return profile, nil -} - -// RunJobLeadSync is the resolver for the runJobLeadSync field. -func (r *mutationResolver) RunJobLeadSync(ctx context.Context) (bool, error) { - if r.Store.JobLeads == nil { - return false, fmt.Errorf("job leads are not configured") - } - return r.Store.JobLeads.RunInBackground(services.LeadJobSync), nil -} - -// ScoreJobLeads is the resolver for the scoreJobLeads field. -func (r *mutationResolver) ScoreJobLeads(ctx context.Context) (bool, error) { - if r.Store.JobLeads == nil { - return false, fmt.Errorf("job leads are not configured") - } - return r.Store.JobLeads.RunInBackground(services.LeadJobScore), nil -} - -// RescoreJobLeads is the resolver for the rescoreJobLeads field. -func (r *mutationResolver) RescoreJobLeads(ctx context.Context) (bool, error) { - if r.Store.JobLeads == nil { - return false, fmt.Errorf("job leads are not configured") - } - return r.Store.JobLeads.RunInBackground(services.LeadJobRescore), nil -} - -// JobSources is the resolver for the jobSources field. -func (r *queryResolver) JobSources(ctx context.Context) ([]*models.JobSource, error) { - var sources []*models.JobSource - if err := r.Store.DB.Order("label ASC, id ASC").Find(&sources).Error; err != nil { - return nil, err - } - return sources, nil -} - -// JobLeads is the resolver for the jobLeads field. -func (r *queryResolver) JobLeads(ctx context.Context, state *string, includeUnmatched *bool) ([]*models.JobLead, error) { - // Omit, not Select: every column but the description, which is tens of - // kilobytes a row and is fetched one lead at a time through jobLead. A - // client that asks for description here gets "". - query := r.Store.DB.Omit("description") - if state != nil { - query = query.Where("state = ?", *state) - } - if includeUnmatched == nil || !*includeUnmatched { - // A promoted or dismissed lead is shown whatever the filter now says - // about it; `matched` only decides what the inbox offers. - query = query.Where("(matched = ? OR state <> ?)", true, services.LeadNew) - } - var leads []*models.JobLead - // Best first, unscored after scored, newest first within a score. The - // limit is a backstop for includeUnmatched on a database holding several - // whole boards. - if err := query.Order("score DESC NULLS LAST, created_at DESC, id DESC").Limit(2000).Find(&leads).Error; err != nil { - return nil, err - } - return leads, nil -} - -// JobLead is the resolver for the jobLead field. -func (r *queryResolver) JobLead(ctx context.Context, id int) (*models.JobLead, error) { - var lead models.JobLead - if err := r.Store.DB.First(&lead, id).Error; err != nil { - return nil, err - } - return &lead, nil -} - -// JobSearchProfile is the resolver for the jobSearchProfile field. -func (r *queryResolver) JobSearchProfile(ctx context.Context) (*models.JobSearchProfile, error) { - return services.LoadJobSearchProfile(r.Store.DB) -} - -// JobLeadSyncStatus is the resolver for the jobLeadSyncStatus field. -func (r *queryResolver) JobLeadSyncStatus(ctx context.Context) (*model.JobLeadSyncStatus, error) { - if r.Store.JobLeads == nil { - return &model.JobLeadSyncStatus{LastError: "job leads are not configured"}, nil - } - status := r.Store.JobLeads.Status() - return &model.JobLeadSyncStatus{Running: status.Running, LastRunAt: status.LastRunAt, LastError: status.LastError}, nil -} diff --git a/backend/graph/job_lead_helpers.go b/backend/graph/job_lead_helpers.go deleted file mode 100644 index 44a88e4..0000000 --- a/backend/graph/job_lead_helpers.go +++ /dev/null @@ -1,31 +0,0 @@ -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 -} diff --git a/backend/graph/model/models_gen.go b/backend/graph/model/models_gen.go index a1a7931..597d650 100644 --- a/backend/graph/model/models_gen.go +++ b/backend/graph/model/models_gen.go @@ -30,33 +30,6 @@ type CreateFavoriteInput struct { Link *string `json:"link,omitempty"` } -type CreateJobAppReferenceInput struct { - Category string `json:"category"` - Label string `json:"label"` - Value string `json:"value"` - SortOrder *int `json:"sortOrder,omitempty"` -} - -type CreateJobApplicationInput struct { - JobTitle string `json:"jobTitle"` - Company string `json:"company"` - Location *string `json:"location,omitempty"` - URL *string `json:"url,omitempty"` - Status string `json:"status"` - Notes *string `json:"notes,omitempty"` - AppliedAt *time.Time `json:"appliedAt,omitempty"` - Description *string `json:"description,omitempty"` -} - -type CreateJobSourceInput struct { - Kind string `json:"kind"` - Label string `json:"label"` - Token *string `json:"token,omitempty"` - Query *string `json:"query,omitempty"` - Location *string `json:"location,omitempty"` - Enabled *bool `json:"enabled,omitempty"` -} - type CreatePlaceInput struct { Title string `json:"title"` Location *string `json:"location,omitempty"` @@ -87,12 +60,6 @@ type GiteaFeedItem struct { CreatedAt time.Time `json:"createdAt"` } -type JobLeadSyncStatus struct { - Running bool `json:"running"` - LastRunAt *time.Time `json:"lastRunAt,omitempty"` - LastError string `json:"lastError"` -} - type LoginInput struct { Username string `json:"username"` Password string `json:"password"` @@ -146,41 +113,6 @@ type SteamStatus struct { RecentGames []*SteamGame `json:"recentGames"` } -type UpdateJobAppReferenceInput struct { - Category *string `json:"category,omitempty"` - Label *string `json:"label,omitempty"` - Value *string `json:"value,omitempty"` - SortOrder *int `json:"sortOrder,omitempty"` -} - -type UpdateJobApplicationInput struct { - JobTitle *string `json:"jobTitle,omitempty"` - Company *string `json:"company,omitempty"` - Location *string `json:"location,omitempty"` - URL *string `json:"url,omitempty"` - Status *string `json:"status,omitempty"` - Notes *string `json:"notes,omitempty"` - AppliedAt *time.Time `json:"appliedAt,omitempty"` - Description *string `json:"description,omitempty"` -} - -type UpdateJobSearchProfileInput struct { - Profile *string `json:"profile,omitempty"` - IncludeKeywords *string `json:"includeKeywords,omitempty"` - ExcludeKeywords *string `json:"excludeKeywords,omitempty"` - Locations *string `json:"locations,omitempty"` - MinScore *int `json:"minScore,omitempty"` -} - -type UpdateJobSourceInput struct { - Kind *string `json:"kind,omitempty"` - Label *string `json:"label,omitempty"` - Token *string `json:"token,omitempty"` - Query *string `json:"query,omitempty"` - Location *string `json:"location,omitempty"` - Enabled *bool `json:"enabled,omitempty"` -} - type UpdatePlaceInput struct { Title *string `json:"title,omitempty"` Location *string `json:"location,omitempty"` diff --git a/backend/graph/schema/job_app_reference.graphql b/backend/graph/schema/job_app_reference.graphql deleted file mode 100644 index 1084c8b..0000000 --- a/backend/graph/schema/job_app_reference.graphql +++ /dev/null @@ -1,38 +0,0 @@ -# Reusable snippets for filling in application forms. Private, like the -# applications themselves, so the query is @admin as well as the mutations. - -type JobAppReference { - id: ID! - createdAt: Time! - updatedAt: Time! - category: String! - label: String! - value: String! - sortOrder: Int! -} - -input CreateJobAppReferenceInput { - category: String! - label: String! - value: String! - sortOrder: Int -} - -input UpdateJobAppReferenceInput { - category: String - label: String - value: String - sortOrder: Int -} - -extend type Query { - jobAppReferences: [JobAppReference!]! @admin -} - -extend type Mutation { - createJobAppReference(input: CreateJobAppReferenceInput!): JobAppReference! @admin - updateJobAppReference(id: ID!, input: UpdateJobAppReferenceInput!): JobAppReference! @admin - # Errors on an id that does not exist, like the other deletes; the Boolean - # is only ever true. - deleteJobAppReference(id: ID!): Boolean! @admin -} diff --git a/backend/graph/schema/job_application.graphql b/backend/graph/schema/job_application.graphql deleted file mode 100644 index e766f05..0000000 --- a/backend/graph/schema/job_application.graphql +++ /dev/null @@ -1,82 +0,0 @@ -# Job application tracker. Rows come from these mutations, automatically from -# the email sync pipeline (backend/services/email_sync.go), from the browser -# capture userscript (backend/handlers/handle_job_capture.go), or from -# promoting a lead (job_lead.graphql). These are private data, so the queries -# here are @admin as well as the mutations. -# -# description is the captured posting text. It can run to tens of kilobytes, -# so the tracker's list query leaves it out and asks for it per row. - -# The lifecycle of an application, in the order the email pipeline and the -# capture endpoint are allowed to advance it. The values are lowercase on -# purpose: they are exactly the strings stored in the status column and ranked -# in services.statusOrder (backend/services/email_sync.go), and a test there -# fails if this list and that map ever differ. Adding a status means adding -# it in both places, and to the tracker page and the capture userscript. -# -# It is bound to a custom marshaller (services/job_status.go, via gqlgen.yml) -# rather than a generated Go type: input is strict, so a mutation carrying a -# status outside this list is refused, while output passes a legacy stored -# value through so one old row cannot fail the whole jobApplications query. -# -# On the wire it is still a JSON string ("applied"), as it was when the field -# was a String, both in variables and in responses. -enum JobStatus { - saved - applied - screening - assessment - interviewing - offer - rejected - withdrawn -} - -type JobApplication { - id: ID! - createdAt: Time! - updatedAt: Time! - jobTitle: String! - company: String! - location: String - url: String - status: JobStatus! - notes: String - appliedAt: Time - description: String -} - -input CreateJobApplicationInput { - jobTitle: String! - company: String! - location: String - url: String - status: JobStatus! - notes: String - appliedAt: Time - description: String -} - -input UpdateJobApplicationInput { - jobTitle: String - company: String - location: String - url: String - status: JobStatus - notes: String - appliedAt: Time - description: String -} - -extend type Query { - jobApplications: [JobApplication!]! @admin - jobApplication(id: ID!): JobApplication @admin -} - -extend type Mutation { - createJobApplication(input: CreateJobApplicationInput!): JobApplication! @admin - updateJobApplication(id: ID!, input: UpdateJobApplicationInput!): JobApplication! @admin - # Errors on an id that does not exist, like the other deletes; the Boolean - # is only ever true. - deleteJobApplication(id: ID!): Boolean! @admin -} diff --git a/backend/graph/schema/job_lead.graphql b/backend/graph/schema/job_lead.graphql deleted file mode 100644 index 9e129dd..0000000 --- a/backend/graph/schema/job_lead.graphql +++ /dev/null @@ -1,145 +0,0 @@ -# Job leads: postings found automatically, as opposed to applications being -# tracked (job_application.graphql). The fetcher in -# backend/services/job_leads.go polls each JobSource, files what it finds as -# JobLead rows and has Claude score them against the JobSearchProfile. A lead -# reaches the tracker only when it is promoted from the leads page. -# -# All of it is private, so every field here is @admin, queries included. - -# One place to poll. `kind` is one of greenhouse, lever, ashby (a company's -# board: `token` is its slug and `label` the company name) or adzuna, reed (a -# keyword search: `query` and `location`, with `label` only a display name). -# It is a String rather than an enum because the resolver validates it and -# the list is the fetcher's to extend (services/job_sources.go). -# -# The last* fields are written by the fetcher, never by a mutation. -type JobSource { - id: ID! - createdAt: Time! - updatedAt: Time! - kind: String! - label: String! - token: String! - query: String! - location: String! - enabled: Boolean! - lastFetchedAt: Time - lastCount: Int! - lastError: String! -} - -input CreateJobSourceInput { - kind: String! - label: String! - token: String - query: String - location: String - enabled: Boolean -} - -input UpdateJobSourceInput { - kind: String - label: String - token: String - query: String - location: String - enabled: Boolean -} - -# description is the posting's full text, tens of kilobytes on some boards, -# so the list query on the leads page leaves it out and asks per row — the -# same arrangement as JobApplication.description. -# -# state is new, dismissed or promoted. score (0-100) and scoreReasons are -# null until Claude has scored the lead, which only happens to matched ones. -type JobLead { - id: ID! - createdAt: Time! - sourceKind: String! - jobTitle: String! - company: String! - location: String! - url: String! - description: String! - postedAt: Time - lastSeenAt: Time! - matched: Boolean! - state: String! - score: Int - scoreReasons: String - scoredAt: Time - jobAppId: ID -} - -# The single row a lead is judged against. profile is free text sent to -# Claude with each posting; the three keyword lists hold one entry per line -# and drive the pre-filter; minScore is the inbox's display threshold. -type JobSearchProfile { - updatedAt: Time! - profile: String! - includeKeywords: String! - excludeKeywords: String! - locations: String! - minScore: Int! -} - -input UpdateJobSearchProfileInput { - profile: String - includeKeywords: String - excludeKeywords: String - locations: String - minScore: Int -} - -# lastRunAt and lastError describe the most recent run in this backend -# process; both reset when it restarts. -type JobLeadSyncStatus { - running: Boolean! - lastRunAt: Time - lastError: String! -} - -extend type Query { - jobSources: [JobSource!]! @admin - # state filters to one of new, dismissed, promoted; omitted returns all. - # Leads that failed the pre-filter are left out unless includeUnmatched. - jobLeads(state: String, includeUnmatched: Boolean): [JobLead!]! @admin - jobLead(id: ID!): JobLead @admin - jobSearchProfile: JobSearchProfile! @admin - jobLeadSyncStatus: JobLeadSyncStatus! @admin -} - -extend type Mutation { - createJobSource(input: CreateJobSourceInput!): JobSource! @admin - updateJobSource(id: ID!, input: UpdateJobSourceInput!): JobSource! @admin - # Errors on an id that does not exist, like the other deletes; the Boolean - # is only ever true. The source's leads are kept. - deleteJobSource(id: ID!): Boolean! @admin - - dismissJobLead(id: ID!): JobLead! @admin - # Puts a dismissed lead back in the inbox. A promoted lead cannot be - # restored: its application exists, and is managed on the tracker. - restoreJobLead(id: ID!): JobLead! @admin - # Adds the lead to the tracker as a saved application — or, if the posting - # is already tracked, links to that row instead of making a second — and - # returns the lead, now promoted, with jobAppId set. - promoteJobLead(id: ID!): JobLead! @admin - - updateJobSearchProfile(input: UpdateJobSearchProfileInput!): JobSearchProfile! @admin - - # Starts a fetch-and-score run in the background and returns at once: true - # if it started, false if one was already running. Poll jobLeadSyncStatus - # to see it finish. - runJobLeadSync: Boolean! @admin - - # Scores every matched lead that has no score yet, without polling any - # source. Background and polled like runJobLeadSync, and refused (false) - # while either is running. - scoreJobLeads: Boolean! @admin - - # Scores every matched inbox lead again, scored or not, for after the - # profile or the model has changed. A lead keeps its old score until its - # new one arrives. Background and polled like the two above, and refused - # (false) while any of the three is running. - rescoreJobLeads: Boolean! @admin -} diff --git a/backend/handlers/handle_email_sync.go b/backend/handlers/handle_email_sync.go deleted file mode 100644 index 34c806e..0000000 --- a/backend/handlers/handle_email_sync.go +++ /dev/null @@ -1,61 +0,0 @@ -package handlers - -import ( - "log" - "net/http" - - "github.com/gin-gonic/gin" -) - -// REST endpoints for the job-application email pipeline: a manual -// admin-triggered sync, and the OAuth redirect target (which has to be REST -// because Microsoft redirects a browser to it). - -// TriggerEmailSync backs the admin-only POST /email/sync and runs one sync -// synchronously, so the response reflects the result. If the scheduler is -// mid-sync the service refuses via TryLock and this returns 500. -func (store *Store) TriggerEmailSync(ctx *gin.Context) { - // A nil HTTPClient is the service's readiness flag — see - // services.EmailSyncService. - if store.EmailSync == nil || store.EmailSync.HTTPClient == nil { - ctx.JSON(http.StatusServiceUnavailable, gin.H{"error": "email sync not configured or not authenticated"}) - return - } - - err := store.EmailSync.SyncEmails(ctx.Request.Context()) - if err != nil { - log.Printf("[EmailSync] Manual sync error: %v", err) - ctx.JSON(http.StatusInternalServerError, gin.H{"error": "sync failed", "details": err.Error()}) - return - } - - ctx.JSON(http.StatusOK, gin.H{"message": "sync completed"}) -} - -// CompleteEmailAuth handles Microsoft's OAuth redirect to -// GET /email/callback and stores the resulting token. -// -// The route is unauthenticated (Microsoft's redirect carries no site cookie), -// which is safe only because the code is worthless without the app's client -// secret. Note that completing auth here does not start the scheduler, which -// only checks readiness at start-up — a restart is needed for that. -func (store *Store) CompleteEmailAuth(ctx *gin.Context) { - if store.EmailSync == nil { - ctx.JSON(http.StatusServiceUnavailable, gin.H{"error": "email sync not configured"}) - return - } - - code := ctx.Query("code") - if code == "" { - ctx.JSON(http.StatusBadRequest, gin.H{"error": "missing authorization code"}) - return - } - - if err := store.EmailSync.CompleteAuth(ctx.Request.Context(), code); err != nil { - log.Printf("[EmailSync] Auth completion error: %v", err) - ctx.JSON(http.StatusInternalServerError, gin.H{"error": "authentication failed"}) - return - } - - ctx.JSON(http.StatusOK, gin.H{"message": "email authentication successful"}) -} diff --git a/backend/handlers/handle_job_capture.go b/backend/handlers/handle_job_capture.go deleted file mode 100644 index cd9fd8d..0000000 --- a/backend/handlers/handle_job_capture.go +++ /dev/null @@ -1,251 +0,0 @@ -package handlers - -import ( - "context" - "errors" - "log" - "net/http" - "strings" - "time" - - "adam-french.co.uk/backend/models" - "adam-french.co.uk/backend/services" - "github.com/gin-gonic/gin" -) - -// Job capture: the three endpoints behind vue/public/job-capture.user.js, -// which adds the posting open in the browser to the job tracker. -// -// These are REST, and token-authenticated, because the caller is a userscript -// running on someone else's origin (linkedin.com, an ATS). The auth cookies -// are SameSite=Lax and never accompany such a request, so the GraphQL -// mutations, which rely on them, are out of reach from there. -// -// The token is deliberately narrow: it opens these routes and nothing else, -// so a token leaked from the browser can add rows to the tracker and spend -// Claude calls, but cannot read the tracker, edit other data or log in. -// -// As with rowing, the Claude call lives in the Python service -// (python/app/jobs.py) and everything touching the database stays here. - -const ( - // jobExtractPath is internal in the same way as rowingReadPath: nginx - // refuses /py/internal/ and the route refuses anything nginx forwarded. - jobExtractPath = "/internal/jobs/extract" - - // maxCaptureBody bounds a capture request. A long posting is tens of - // kilobytes of text; the userscript trims the page to maxPageRunes before - // sending, so anything near this limit is not a job page. - maxCaptureBody = 512 << 10 - - // maxPageRunes caps both the text sent to Claude and the description - // stored. It mirrors MAX_TEXT_CHARS in python/app/jobs.py, which rejects - // anything longer, so the cut has to happen on this side. - maxPageRunes = 40_000 -) - -// CaptureTokenMiddleware guards the capture routes with the token generated -// in the admin panel (services.CaptureToken), presented as -// "Authorization: Bearer ". -// -// Until a token has been generated the routes are off (503) rather than -// open; "no token" must never be satisfied by a request that sends none. -func (store *Store) CaptureTokenMiddleware(ctx *gin.Context) { - if store.CaptureToken == nil { - ctx.AbortWithStatusJSON(http.StatusServiceUnavailable, gin.H{"error": "job capture is not configured"}) - return - } - if set, _ := store.CaptureToken.Status(); !set { - ctx.AbortWithStatusJSON(http.StatusServiceUnavailable, gin.H{"error": "no capture token has been generated"}) - return - } - presented, ok := strings.CutPrefix(ctx.GetHeader("Authorization"), "Bearer ") - if !ok || !store.CaptureToken.Verify(presented) { - ctx.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"error": "unauthorized"}) - return - } - ctx.Next() -} - -// The three handlers below manage that token from the admin panel. They sit -// in the cookie-authenticated admin group, not behind the token: the token -// must not be able to replace itself. - -func captureTokenStatus(token *services.CaptureToken) gin.H { - set, createdAt := token.Status() - if !set { - return gin.H{"set": false} - } - return gin.H{"set": true, "createdAt": createdAt} -} - -// GetCaptureToken backs GET /admin/capture-token: whether a token exists and -// when it was made. The token itself is not recoverable — only its hash is -// stored. -func (store *Store) GetCaptureToken(ctx *gin.Context) { - ctx.JSON(http.StatusOK, captureTokenStatus(store.CaptureToken)) -} - -// GenerateCaptureToken backs POST /admin/capture-token. It replaces any -// existing token, so the userscript must be reconfigured with the new one, -// and its response is the only time the token is ever sent anywhere. -func (store *Store) GenerateCaptureToken(ctx *gin.Context) { - token, createdAt, err := store.CaptureToken.Generate() - if err != nil { - log.Println("Generating capture token failed:", err) - ctx.JSON(http.StatusInternalServerError, gin.H{"error": "failed to store the token"}) - return - } - // The response carries a credential; keep it out of any cache. - ctx.Header("Cache-Control", "no-store") - ctx.JSON(http.StatusOK, gin.H{"token": token, "createdAt": createdAt}) -} - -// RevokeCaptureToken backs DELETE /admin/capture-token, switching the capture -// routes off until a new token is generated. -func (store *Store) RevokeCaptureToken(ctx *gin.Context) { - if err := store.CaptureToken.Revoke(); err != nil { - log.Println("Revoking capture token failed:", err) - ctx.JSON(http.StatusInternalServerError, gin.H{"error": "failed to revoke the token"}) - return - } - ctx.JSON(http.StatusOK, captureTokenStatus(store.CaptureToken)) -} - -// capturedJob is the slice of an application the userscript needs back: enough -// to show "already tracked as …" and no more. The token is not meant to be -// able to read the tracker, so notes and the description stay out of it. -type capturedJob struct { - ID uint `json:"id"` - JobTitle string `json:"jobTitle"` - Company string `json:"company"` - Status string `json:"status"` -} - -func capturedJobOf(app *models.JobApplication) *capturedJob { - return &capturedJob{ID: app.ID, JobTitle: app.JobTitle, Company: app.Company, Status: app.Status} -} - -// JobCaptureStatus backs GET /jobs/capture/status?url=. It is what lets the -// userscript show a posting's tracked status instead of an "add" button. -func (store *Store) JobCaptureStatus(ctx *gin.Context) { - raw := ctx.Query("url") - canonical, ok := services.CanonicalJobURL(raw) - if !ok { - ctx.JSON(http.StatusBadRequest, gin.H{"error": "url must be an absolute http(s) URL"}) - return - } - app, err := services.FindApplicationByURL(store.DB, canonical, raw) - if err != nil { - log.Println("Job capture status lookup failed:", err) - ctx.JSON(http.StatusInternalServerError, gin.H{"error": "lookup failed"}) - return - } - if app == nil { - ctx.JSON(http.StatusOK, gin.H{"found": false}) - return - } - ctx.JSON(http.StatusOK, gin.H{"found": true, "application": capturedJobOf(app)}) -} - -// ExtractedJobPosting is the JSON contract for what Claude reads off a job -// page: the body of the Python service's reply (JobPosting in -// python/app/jobs.py). Empty strings and nulls mean "not found on the page". -type ExtractedJobPosting struct { - JobTitle string `json:"jobTitle"` - Company string `json:"company"` - Location *string `json:"location"` - Notes *string `json:"notes"` -} - -// extractJobPosting sends a page's text to the Python service and returns the -// fields Claude picked out. Like readRowingDisplay it is a thin wrapper over -// services.CallPython, which decides which replies are relayed (a -// *services.PythonError) and which are only logged. -func (store *Store) extractJobPosting(ctx context.Context, pageURL, title, text string) (ExtractedJobPosting, error) { - return services.CallPython[ExtractedJobPosting](ctx, store.PythonURL, jobExtractPath, struct { - URL string `json:"url"` - Title string `json:"title"` - Text string `json:"text"` - }{pageURL, title, text}) -} - -// truncateRunes cuts s to at most max runes, on a rune boundary so the result -// is still valid UTF-8 for Postgres and for JSON. -func truncateRunes(s string, max int) string { - runes := []rune(s) - if len(runes) <= max { - return s - } - return string(runes[:max]) -} - -// bindCapture decodes a size-limited JSON body, answering 400 itself when it -// cannot. -func bindCapture(ctx *gin.Context, into any) bool { - ctx.Request.Body = http.MaxBytesReader(ctx.Writer, ctx.Request.Body, maxCaptureBody) - if err := ctx.ShouldBindJSON(into); err != nil { - ctx.JSON(http.StatusBadRequest, gin.H{"error": "invalid request body"}) - return false - } - return true -} - -// JobCaptureExtract backs POST /jobs/capture/extract: page text in, the -// popup's pre-filled fields out. Nothing is stored; saving is a separate -// request made once the fields have been checked by eye. -func (store *Store) JobCaptureExtract(ctx *gin.Context) { - var input struct { - URL string `json:"url"` - Title string `json:"title"` - Text string `json:"text"` - } - if !bindCapture(ctx, &input) { - return - } - text := strings.TrimSpace(input.Text) - if text == "" { - ctx.JSON(http.StatusBadRequest, gin.H{"error": "text is required"}) - return - } - - posting, err := store.extractJobPosting(ctx.Request.Context(), - truncateRunes(input.URL, 2000), truncateRunes(input.Title, 500), truncateRunes(text, maxPageRunes)) - if err != nil { - log.Println("Job extract failed:", err) - var readErr *services.PythonError - if errors.As(err, &readErr) { - ctx.JSON(http.StatusBadGateway, gin.H{"error": readErr.Detail}) - return - } - ctx.JSON(http.StatusBadGateway, gin.H{"error": "failed to read the page"}) - return - } - ctx.JSON(http.StatusOK, posting) -} - -// JobCapture backs POST /jobs/capture, an upsert: a posting already in the -// tracker is updated in place rather than added again. The matching and -// merging rules are services.UpsertJobApplication's; this handler owns the -// request body and the status codes. -func (store *Store) JobCapture(ctx *gin.Context) { - var input services.JobCaptureInput - if !bindCapture(ctx, &input) { - return - } - input.Description = truncateRunes(strings.TrimSpace(input.Description), maxPageRunes) - - app, action, err := services.UpsertJobApplication(store.DB, input, time.Now()) - var invalid *services.JobInputError - switch { - case errors.As(err, &invalid): - ctx.JSON(http.StatusBadRequest, gin.H{"error": invalid.Error()}) - case err != nil: - log.Println("Job capture failed:", err) - ctx.JSON(http.StatusInternalServerError, gin.H{"error": "failed to save"}) - case action == "created": - ctx.JSON(http.StatusCreated, gin.H{"action": action, "application": capturedJobOf(app)}) - default: - ctx.JSON(http.StatusOK, gin.H{"action": action, "application": capturedJobOf(app)}) - } -} diff --git a/backend/handlers/handle_job_capture_test.go b/backend/handlers/handle_job_capture_test.go deleted file mode 100644 index 26df72c..0000000 --- a/backend/handlers/handle_job_capture_test.go +++ /dev/null @@ -1,264 +0,0 @@ -package handlers - -import ( - "context" - "encoding/json" - "errors" - "net/http" - "net/http/httptest" - "path/filepath" - "strings" - "testing" - - "adam-french.co.uk/backend/services" - "github.com/gin-gonic/gin" -) - -// The capture handlers themselves need a database, and the only driver in -// go.mod is postgres, so what is covered here is everything around the -// queries: the token gate, the URL key that decides whether a posting is -// already tracked, the merge rule for a repeat capture, and the call to the -// Python service. - -func TestCaptureTokenMiddleware(t *testing.T) { - gin.SetMode(gin.TestMode) - - serve := func(store *Store, header string) int { - r := gin.New() - r.GET("/x", store.CaptureTokenMiddleware, func(ctx *gin.Context) { ctx.Status(http.StatusOK) }) - req := httptest.NewRequest(http.MethodGet, "/x", nil) - if header != "" { - req.Header.Set("Authorization", header) - } - rec := httptest.NewRecorder() - r.ServeHTTP(rec, req) - return rec.Code - } - newToken := func() *services.CaptureToken { - tok, err := services.InitCaptureToken(filepath.Join(t.TempDir(), "token.json")) - if err != nil { - t.Fatalf("InitCaptureToken: %v", err) - } - return tok - } - - // The case the middleware exists to get right: with no token generated, - // a request presenting nothing (or an empty bearer) must not get in. - t.Run("no token generated switches the routes off", func(t *testing.T) { - store := &Store{CaptureToken: newToken()} - for _, header := range []string{"", "Bearer ", "Bearer anything"} { - if got := serve(store, header); got != http.StatusServiceUnavailable { - t.Fatalf("header %q: status = %d, want 503", header, got) - } - } - }) - t.Run("a store built without the token service is off too", func(t *testing.T) { - if got := serve(&Store{}, "Bearer x"); got != http.StatusServiceUnavailable { - t.Fatalf("status = %d, want 503", got) - } - }) - - store := &Store{CaptureToken: newToken()} - token, _, err := store.CaptureToken.Generate() - if err != nil { - t.Fatalf("Generate: %v", err) - } - cases := []struct { - name string - header string - want int - }{ - {"the generated token is let through", "Bearer " + token, http.StatusOK}, - {"a wrong token is refused", "Bearer nope", http.StatusUnauthorized}, - {"no header is refused", "", http.StatusUnauthorized}, - {"the bare token without the scheme is refused", token, http.StatusUnauthorized}, - } - for _, c := range cases { - t.Run(c.name, func(t *testing.T) { - if got := serve(store, c.header); got != c.want { - t.Fatalf("status = %d, want %d", got, c.want) - } - }) - } -} - -// The admin endpoints, driven without the admin middleware (covered -// elsewhere): generate shows the token once, status never does, and a second -// generate or a revoke stops the first token working. -func TestCaptureTokenAdminEndpoints(t *testing.T) { - gin.SetMode(gin.TestMode) - tok, err := services.InitCaptureToken(filepath.Join(t.TempDir(), "token.json")) - if err != nil { - t.Fatalf("InitCaptureToken: %v", err) - } - store := &Store{CaptureToken: tok} - r := gin.New() - r.GET("/t", store.GetCaptureToken) - r.POST("/t", store.GenerateCaptureToken) - r.DELETE("/t", store.RevokeCaptureToken) - - call := func(method string) (map[string]any, *httptest.ResponseRecorder) { - rec := httptest.NewRecorder() - r.ServeHTTP(rec, httptest.NewRequest(method, "/t", nil)) - if rec.Code != http.StatusOK { - t.Fatalf("%s: status = %d, body = %s", method, rec.Code, rec.Body) - } - var out map[string]any - json.Unmarshal(rec.Body.Bytes(), &out) - return out, rec - } - - if out, _ := call(http.MethodGet); out["set"] != false { - t.Fatalf("fresh status = %v", out) - } - - out, rec := call(http.MethodPost) - first, _ := out["token"].(string) - if !tok.Verify(first) { - t.Fatalf("generated token %q does not verify", first) - } - if rec.Header().Get("Cache-Control") != "no-store" { - t.Fatal("the response carrying the token must not be cacheable") - } - - out, _ = call(http.MethodGet) - if out["set"] != true || out["createdAt"] == nil { - t.Fatalf("status after generate = %v", out) - } - if _, leaked := out["token"]; leaked { - t.Fatal("status must never return the token") - } - - call(http.MethodPost) - if tok.Verify(first) { - t.Fatal("regenerating must invalidate the previous token") - } - - if out, _ := call(http.MethodDelete); out["set"] != false { - t.Fatalf("status after revoke = %v", out) - } -} - -func TestTruncateRunes(t *testing.T) { - if got := truncateRunes("££££", 2); got != "££" { - t.Fatalf("got %q; the cut must fall on a rune boundary", got) - } - if got := truncateRunes("short", 10); got != "short" { - t.Fatalf("got %q", got) - } -} - -func jobExtractor(t *testing.T, handler http.HandlerFunc) *Store { - t.Helper() - srv := httptest.NewServer(handler) - t.Cleanup(srv.Close) - return &Store{PythonURL: srv.URL} -} - -func TestExtractJobPostingRequestAndReply(t *testing.T) { - var got map[string]string - var path string - var forwarded bool - store := jobExtractor(t, func(w http.ResponseWriter, r *http.Request) { - path = r.URL.Path - // As with the rowing reader, either header makes the Python route - // answer 404. - forwarded = r.Header.Get("X-Real-IP") != "" || r.Header.Get("X-Forwarded-For") != "" - if err := json.NewDecoder(r.Body).Decode(&got); err != nil { - t.Errorf("decoding request: %v", err) - } - w.Write([]byte(`{"jobTitle": "Engineer", "company": "Acme", "location": "London", "notes": null}`)) - }) - - posting, err := store.extractJobPosting(context.Background(), "https://x.com/1", "Engineer | Acme", "page text") - if err != nil { - t.Fatalf("extractJobPosting: %v", err) - } - if posting.JobTitle != "Engineer" || posting.Company != "Acme" || posting.Location == nil || *posting.Location != "London" || posting.Notes != nil { - t.Fatalf("got %+v", posting) - } - if path != jobExtractPath { - t.Fatalf("path = %q, want %q", path, jobExtractPath) - } - if forwarded { - t.Fatal("request carried a proxy header the Python route rejects") - } - if got["url"] != "https://x.com/1" || got["title"] != "Engineer | Acme" || got["text"] != "page text" { - t.Fatalf("request body = %+v", got) - } -} - -func TestExtractJobPostingErrors(t *testing.T) { - cases := []struct { - name string - status int - body string - wantDetail string // non-empty: a services.PythonError with this message - }{ - {"extractor failure is relayed", http.StatusBadGateway, `{"detail": "failed to parse the posting"}`, "failed to parse the posting"}, - {"validation error is not relayed", http.StatusUnprocessableEntity, `{"detail": [{"msg": "bad"}]}`, ""}, - {"missing key is not relayed", http.StatusServiceUnavailable, `{"detail": "CLAUDE_API_KEY is not set"}`, ""}, - {"malformed success body", http.StatusOK, `not json`, ""}, - } - for _, c := range cases { - t.Run(c.name, func(t *testing.T) { - store := jobExtractor(t, func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(c.status) - w.Write([]byte(c.body)) - }) - _, err := store.extractJobPosting(context.Background(), "https://x.com/1", "t", "text") - if err == nil { - t.Fatal("expected an error") - } - var readErr *services.PythonError - if relayed := errors.As(err, &readErr); relayed != (c.wantDetail != "") { - t.Fatalf("relayed = %v, err = %v", relayed, err) - } - if readErr != nil && readErr.Detail != c.wantDetail { - t.Fatalf("detail = %q, want %q", readErr.Detail, c.wantDetail) - } - }) - } -} - -// The extract handler runs without a database, so it can be driven whole: the -// page text must be cut to the limit the Python side enforces before it is -// forwarded, or a long page would come back as an opaque 422. -func TestJobCaptureExtractTruncatesAndRelays(t *testing.T) { - gin.SetMode(gin.TestMode) - var forwardedLen int - store := jobExtractor(t, func(w http.ResponseWriter, r *http.Request) { - var body map[string]string - json.NewDecoder(r.Body).Decode(&body) - forwardedLen = len([]rune(body["text"])) - w.Write([]byte(`{"jobTitle": "Engineer", "company": "Acme", "location": null, "notes": null}`)) - }) - r := gin.New() - r.POST("/extract", store.JobCaptureExtract) - - post := func(body string) *httptest.ResponseRecorder { - rec := httptest.NewRecorder() - r.ServeHTTP(rec, httptest.NewRequest(http.MethodPost, "/extract", strings.NewReader(body))) - return rec - } - - long, _ := json.Marshal(map[string]string{"url": "https://x.com/1", "title": "t", "text": strings.Repeat("é", maxPageRunes+500)}) - rec := post(string(long)) - if rec.Code != http.StatusOK { - t.Fatalf("status = %d, body = %s", rec.Code, rec.Body) - } - if forwardedLen != maxPageRunes { - t.Fatalf("forwarded %d runes, want %d", forwardedLen, maxPageRunes) - } - var out ExtractedJobPosting - if err := json.Unmarshal(rec.Body.Bytes(), &out); err != nil || out.Company != "Acme" { - t.Fatalf("body = %s (%v)", rec.Body, err) - } - - if rec := post(`{"url": "https://x.com/1", "text": " "}`); rec.Code != http.StatusBadRequest { - t.Fatalf("blank text: status = %d", rec.Code) - } - if rec := post(`not json`); rec.Code != http.StatusBadRequest { - t.Fatalf("bad body: status = %d", rec.Code) - } -} diff --git a/backend/handlers/store.go b/backend/handlers/store.go index 90c2524..4edf739 100644 --- a/backend/handlers/store.go +++ b/backend/handlers/store.go @@ -32,24 +32,12 @@ type Store struct { Auth *services.Auth Notes *services.Notes LoginLimiter *services.RateLimiter - EmailSync *services.EmailSyncService - // JobLeads is the lead fetcher (services/job_leads.go). The GraphQL - // resolvers use it to start a run and report on one. - JobLeads *services.JobLeadService // Base URL of the Python service on the Docker network, no trailing // slash. Used for the calls that bypass nginx, all through - // services.CallPython: reading a rowing display photo (handle_rowing.go) - // and a job posting (handle_job_capture.go). The email pipeline and the - // lead pipeline make the other two such calls and hold their own copies - // of this value. + // services.CallPython: reading a rowing display photo (handle_rowing.go). PythonURL string - // Bearer token for the browser capture routes (handle_job_capture.go), - // generated from the admin panel. Nil, or holding no token, means those - // routes are switched off, not open. - CaptureToken *services.CaptureToken - // Registry of .env variables and the request/status hand-off with the // host that applies changes to them (handle_env.go). Env *services.EnvManager diff --git a/backend/main.go b/backend/main.go index e9db204..bc809cf 100644 --- a/backend/main.go +++ b/backend/main.go @@ -89,10 +89,10 @@ func main() { spotifyConfig := services.SpotifyConfig{RedirectURL: spotifyRedirectURL, ClientID: spotifyClientID, ClientSecret: spotifyClientSecret} spotifyAuth, spotifyClient := services.InitSpotifyAuth(&spotifyConfig) - // No Claude client here: every Claude call — the rowing photo reader, the - // job posting reader and the email classifier — is made by the Python - // service, which is the only container that reads CLAUDE_API_KEY. The - // backend reaches those routes at pythonURL, below. + // No Claude client here: the site's one Claude call, the rowing photo + // reader, is made by the Python service, which is the only container of + // the site's own that reads CLAUDE_API_KEY. The backend reaches it at + // pythonURL, below. (The job tracker, a separate container, makes its own.) authSecret := os.Getenv("BACKEND_SECRET") backendEndpoint := os.Getenv("BACKEND_ENDPOINT") @@ -116,7 +116,7 @@ func main() { // PYTHON SERVICE // Called directly over the Docker network, not through nginx, for its - // four /internal/ Claude routes (services/python_call.go). The defaults + // /internal/ Claude route (services/python_call.go). The defaults // mirror docker-compose.yml, where both variables are optional. pythonHost := os.Getenv("PYTHON_HOST") if pythonHost == "" { @@ -128,63 +128,10 @@ func main() { } pythonURL := fmt.Sprintf("http://%s:%s", pythonHost, pythonPort) - // EMAIL SYNC - // An unparseable EMAIL_SYNC_INTERVAL is silently ignored and the 30 - // minute default stands — a typo here fails quietly. - emailSyncInterval := 30 * time.Minute - if interval := os.Getenv("EMAIL_SYNC_INTERVAL"); interval != "" { - if parsed, err := time.ParseDuration(interval); err == nil { - emailSyncInterval = parsed - } - } - emailSyncConfig := services.EmailSyncConfig{ - Backend: os.Getenv("EMAIL_BACKEND"), - ClientID: os.Getenv("MSGRAPH_CLIENT_ID"), - ClientSecret: os.Getenv("MSGRAPH_CLIENT_SECRET"), - TenantID: os.Getenv("MSGRAPH_TENANT_ID"), - RedirectURI: os.Getenv("MSGRAPH_REDIRECT_URI"), - IMAP: &services.IMAPConfig{ - Host: os.Getenv("IMAP_HOST"), - Port: os.Getenv("IMAP_PORT"), - Email: os.Getenv("IMAP_EMAIL"), - Password: os.Getenv("IMAP_PASSWORD"), - }, - SyncInterval: emailSyncInterval, - Enabled: os.Getenv("EMAIL_SYNC_ENABLED") == "true", - } - emailSync := services.InitEmailSync(&emailSyncConfig, db, pythonURL) - - // JOB LEADS - // Like EMAIL_SYNC_INTERVAL, an unparseable JOB_LEADS_INTERVAL is ignored - // and the default stands. Six hours: boards change a few times a day at - // most, and every run can spend Claude calls. - jobLeadsInterval := 6 * time.Hour - if interval := os.Getenv("JOB_LEADS_INTERVAL"); interval != "" { - if parsed, err := time.ParseDuration(interval); err == nil && parsed > 0 { - jobLeadsInterval = parsed - } - } - jobLeads := services.InitJobLeads(&services.JobLeadConfig{ - Enabled: os.Getenv("JOB_LEADS_ENABLED") == "true", - Interval: jobLeadsInterval, - AdzunaAppID: os.Getenv("ADZUNA_APP_ID"), - AdzunaAppKey: os.Getenv("ADZUNA_APP_KEY"), - ReedAPIKey: os.Getenv("REED_API_KEY"), - }, db, pythonURL) - // 5 login attempts per IP per minute, applied by both the REST handler // and the GraphQL login mutation. Nginx rate-limits the login route too. loginLimiter := services.NewRateLimiter(5, time.Minute) - // JOB CAPTURE - // The userscript's bearer token is generated in the admin panel and kept - // (hashed) beside the OAuth tokens. A damaged file is logged, not fatal: - // capture stays off until a new token is generated. - captureToken, err := services.InitCaptureToken(services.CAPTURE_TOKEN_JSON_PATH) - if err != nil { - log.Println("Job capture token not loaded:", err) - } - // ENVIRONMENT // The registry is embedded, so the only way this fails is a malformed // env_registry.json — a build mistake worth stopping for. @@ -193,7 +140,7 @@ func main() { log.Fatal(err) } - store := handlers.Store{DB: db, SpotifyAuth: spotifyAuth, SpotifyClient: spotifyClient, Auth: auth, Notes: notes, LoginLimiter: loginLimiter, EmailSync: emailSync, JobLeads: jobLeads, GiteaHost: giteaHost, GiteaPort: giteaPort, SteamAPIKey: steamAPIKey, SteamID: steamID, PythonURL: pythonURL, CaptureToken: captureToken, Env: envManager} + store := handlers.Store{DB: db, SpotifyAuth: spotifyAuth, SpotifyClient: spotifyClient, Auth: auth, Notes: notes, LoginLimiter: loginLimiter, GiteaHost: giteaHost, GiteaPort: giteaPort, SteamAPIKey: steamAPIKey, SteamID: steamID, PythonURL: pythonURL, Env: envManager} // Route groups. AdminMiddleware reads the claims AuthMiddlewear stored in // the Gin context, so the order in the admin group matters. @@ -202,12 +149,6 @@ func main() { protected := r.Group("/", store.AuthMiddlewear) admin := r.Group("/", store.AuthMiddlewear, store.AdminMiddleware) - // JOB CAPTURE and EMAIL SYNC routes moved to the job tracker app - // (adamf/job-tracker, served at /jobs/). They are no longer registered - // here, so an old userscript gets a 404 instead of writing into tables - // the tracker no longer reads. The handlers are deleted in a later - // commit, once the tracker has run for a while. - // ROWING r.GET("/rowing", store.GetRowing) admin.POST("/rowing", store.CreateRowing) @@ -252,11 +193,6 @@ func main() { admin.PUT("/admin/env", store.UpdateEnv) admin.GET("/admin/env/status", store.GetEnvStatus) admin.DELETE("/admin/env/pending", store.CancelEnv) - // The job capture token is managed with the session cookie, never with - // the token itself. - admin.GET("/admin/capture-token", store.GetCaptureToken) - admin.POST("/admin/capture-token", store.GenerateCaptureToken) - admin.DELETE("/admin/capture-token", store.RevokeCaptureToken) // GRAPHQL // GraphQL is assembled by hand rather than with handler.NewDefaultServer @@ -308,11 +244,6 @@ func main() { c.JSON(200, gin.H{"message": "Hello World"}) }) - // The email sync and job-lead schedulers are NOT started: the job tracker - // runs them now, and it reads the same EMAIL_SYNC_ENABLED and - // JOB_LEADS_ENABLED from .env, so starting them here as well would - // process every email and board twice. - port := os.Getenv("BACKEND_PORT") // Blocks until the server stops. Any return is a failure — a port clash, // most often — so it must exit non-zero, or Docker sees a clean shutdown diff --git a/backend/models/models.go b/backend/models/models.go index 5a1d47d..4e07a59 100644 --- a/backend/models/models.go +++ b/backend/models/models.go @@ -138,57 +138,6 @@ type Bookmark struct { Link string `gorm:"not null" json:"link"` } -// JobAppReference is a reusable snippet for filling in job application forms -// (a stock answer, a profile link, and so on), grouped by Category and -// ordered within it by SortOrder. -type JobAppReference struct { - ID uint `gorm:"primarykey" json:"id"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - DeletedAt gorm.DeletedAt `gorm:"index" json:"deletedAt"` - Category string `gorm:"not null" json:"category"` - Label string `gorm:"not null" json:"label"` - Value string `gorm:"not null" json:"value"` - SortOrder int `gorm:"default:0" json:"sortOrder"` -} - -// ProcessedEmail records that the email pipeline has already looked at a -// message, so it is never classified twice. -// -// Unlike every other model it has no DeletedAt and so is NOT soft deleted — -// the dedup check must see every historical row. Its CreatedAt also drives -// the next sync's time window, so the most recent row here is effectively the -// pipeline's cursor. A row is written even when classification failed, with -// Action "error", which means failures are never retried. -type ProcessedEmail struct { - ID uint `gorm:"primarykey" json:"id"` - CreatedAt time.Time `json:"createdAt"` - // The provider's message id: Microsoft Graph's id on the Graph backend, - // the RFC822 Message-ID header on IMAP. Unique, which is what makes the - // dedup check safe against a concurrent sync. - GraphMessageID string `gorm:"uniqueIndex;not null" json:"graphMessageId"` - Subject string `gorm:"not null" json:"subject"` - Action string `gorm:"not null" json:"action"` - // The application this email created or updated, if any. A plain nullable - // column, not a GORM association — nothing preloads it. - JobAppID *uint `json:"jobAppId"` - // Attempts counts how many times processing this email has been tried. - // A row with Action "error" and Attempts below the cap is retryable: the - // next sync re-processes it instead of skipping it. Once Attempts reaches - // the cap the row becomes terminal, so a genuinely unprocessable email - // (one Claude can never parse) eventually stops consuming API calls. - // Rows written before this column existed default to 1 and so get their - // remaining attempts. - Attempts int `gorm:"not null;default:1" json:"attempts"` - // ReceivedAt is the provider's own timestamp for the email, as distinct - // from CreatedAt (when we processed it). It exists so a retryable failure - // can pull the fetch window back far enough to actually re-fetch the - // email: the window is otherwise anchored to processing time, which would - // have already advanced past it. Zero for rows written before this - // column existed, and for those the clamp is skipped. - ReceivedAt time.Time `json:"receivedAt"` -} - // Place is an entry on the places-to-go list. Creating or editing one needs // only a signed-in user, not an admin — the one exception to the // admin-writes-everything rule. @@ -206,131 +155,3 @@ type Place struct { Priority int `gorm:"default:0" json:"priority"` Done bool `gorm:"default:false" json:"done"` } - -// JobApplication is a tracked job application. Rows are created by hand -// through GraphQL, automatically by the email pipeline, from the browser by -// the capture userscript (handlers/handle_job_capture.go), or by promoting a -// JobLead (services.PromoteJobLead). -// -// Status is a plain string column, but its vocabulary is fixed: the values -// ranked in services.statusOrder ("saved", "applied", "screening", -// "assessment", "interviewing", "offer", "rejected", "withdrawn"), which the -// GraphQL schema repeats as `enum JobStatus`. Every writer keeps to it — -// GraphQL refuses anything else, the email pipeline and the capture endpoint -// coerce with services.NormalizeStatus — but the column predates that, so a -// reader must not assume an old row conforms (services.MarshalJobStatus does -// not). The pipeline matches an existing application on (Company, JobTitle) -// compared case-insensitively. -// -// Description is the posting's text as captured from the page, kept because -// postings are usually taken down long before the interview. It is large, so -// list queries should not select it. -type JobApplication struct { - ID uint `gorm:"primarykey" json:"id"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - DeletedAt gorm.DeletedAt `gorm:"index" json:"deletedAt"` - JobTitle string `gorm:"not null" json:"jobTitle"` - Company string `gorm:"not null" json:"company"` - Location *string `json:"location"` - URL *string `json:"url"` - Status string `gorm:"not null" json:"status"` - Notes *string `json:"notes"` - AppliedAt *time.Time `json:"appliedAt"` - Description *string `gorm:"type:text" json:"description"` -} - -// JobSource is one place the lead fetcher (services/job_leads.go) polls for -// postings. Kind decides which of the other fields mean anything: -// -// - "greenhouse", "lever", "ashby": one company's public job board. Token is -// the board's slug (the "acme" in boards.greenhouse.io/acme) and Label is -// the company name every lead from it is filed under. -// - "adzuna", "reed": a keyword search. Query and Location are the search -// terms and Label is only a display name; the company comes from each -// result. -// -// The Last* fields are written by the fetcher after every poll and are what -// the leads page shows beside the source. LastError is "" after a clean poll. -type JobSource struct { - ID uint `gorm:"primarykey" json:"id"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - DeletedAt gorm.DeletedAt `gorm:"index" json:"deletedAt"` - Kind string `gorm:"not null" json:"kind"` - Label string `gorm:"not null" json:"label"` - Token string `json:"token"` - Query string `json:"query"` - Location string `json:"location"` - // No `default:true` tag: GORM applies a default to a zero value on - // insert, which would make it impossible to create a source disabled. - Enabled bool `gorm:"not null" json:"enabled"` - LastFetchedAt *time.Time `json:"lastFetchedAt"` - LastCount int `gorm:"not null;default:0" json:"lastCount"` - LastError string `json:"lastError"` -} - -// JobLead is a posting the fetcher found, waiting in the leads inbox to be -// tracked or dismissed. It is deliberately not a JobApplication: a single -// company board is hundreds of postings, almost all irrelevant, and the -// tracker, its status vocabulary and the email matcher are about jobs -// actually applied to. -// -// Like ProcessedEmail it has no DeletedAt and is NOT soft deleted. The -// (SourceKind, ExternalID) unique index is the dedup that stops every poll -// re-adding the same posting, and it only works if a dismissed lead is still -// a row: dismissal is State "dismissed", never a delete. -// -// ExternalID is the source's own id for the posting. For the board kinds it -// is "/", because ids are only unique within one board. -// -// State is "new", "dismissed" or "promoted" (see the LeadState constants in -// services/job_leads.go). JobAppID is set on a promoted lead and is a plain -// nullable column, not a GORM association. -// -// Matched says whether the lead passed the keyword pre-filter the last time -// the fetcher ran; only matched leads are shown by default and only they are -// scored. Score (0-100) and ScoreReasons are Claude's, and nil until scored. -// ScoredAt is when that score was given, which is how a rescore tells the -// leads it has redone from the ones it has yet to reach; it is nil on a lead -// scored before the column existed. ScoreAttempts counts failed tries, so a -// posting Claude can never score stops costing a call per run. -type JobLead struct { - ID uint `gorm:"primarykey" json:"id"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - SourceID uint `gorm:"index" json:"sourceId"` - SourceKind string `gorm:"not null;uniqueIndex:idx_job_lead_external" json:"sourceKind"` - ExternalID string `gorm:"not null;uniqueIndex:idx_job_lead_external" json:"externalId"` - JobTitle string `gorm:"not null" json:"jobTitle"` - Company string `gorm:"not null" json:"company"` - Location string `json:"location"` - URL string `json:"url"` - Description string `gorm:"type:text" json:"description"` - PostedAt *time.Time `json:"postedAt"` - LastSeenAt time.Time `json:"lastSeenAt"` - Matched bool `gorm:"not null;default:false;index" json:"matched"` - State string `gorm:"not null;default:new;index" json:"state"` - Score *int `json:"score"` - ScoreReasons *string `json:"scoreReasons"` - ScoredAt *time.Time `json:"scoredAt"` - ScoreAttempts int `gorm:"not null;default:0" json:"scoreAttempts"` - JobAppID *uint `json:"jobAppId"` -} - -// JobSearchProfile is what a lead is judged against. There is exactly one -// row, with ID 1, created on first read (services.LoadJobSearchProfile). -// -// Profile is free text about experience and what kind of job is wanted; it is -// sent to Claude with each posting. The three keyword lists hold one entry -// per line and drive the cheap pre-filter that runs before any Claude call. -// MinScore is only a display threshold for the inbox. -type JobSearchProfile struct { - ID uint `gorm:"primarykey" json:"id"` - UpdatedAt time.Time `json:"updatedAt"` - Profile string `gorm:"type:text" json:"profile"` - IncludeKeywords string `gorm:"type:text" json:"includeKeywords"` - ExcludeKeywords string `gorm:"type:text" json:"excludeKeywords"` - Locations string `gorm:"type:text" json:"locations"` - MinScore int `gorm:"not null;default:60" json:"minScore"` -} diff --git a/backend/services/capture_token.go b/backend/services/capture_token.go deleted file mode 100644 index 6dd300b..0000000 --- a/backend/services/capture_token.go +++ /dev/null @@ -1,133 +0,0 @@ -package services - -import ( - "crypto/rand" - "crypto/sha256" - "crypto/subtle" - "encoding/hex" - "encoding/json" - "errors" - "fmt" - "io/fs" - "os" - "path/filepath" - "sync" - "time" -) - -// CAPTURE_TOKEN_JSON_PATH sits beside the Spotify and Graph tokens, in the -// directory docker-compose bind-mounts so that it survives a rebuild. -const CAPTURE_TOKEN_JSON_PATH = "/backend/token/job_capture_token.json" - -// CaptureToken holds the bearer token the job capture userscript presents -// (handlers/handle_job_capture.go). The token is minted from the admin panel -// rather than set in .env, so it can be replaced without a redeploy when the -// browser profile holding it is lost. -// -// Only a SHA-256 of the token is kept, in memory and on disk: the token is -// shown once, when generated, and cannot be read back afterwards. A plain -// hash is enough because the token is 32 random bytes, not a password — there -// is nothing to brute-force. -// -// There is at most one token. Generating replaces it, which is also how a -// leaked one is rotated. -type CaptureToken struct { - path string - - mu sync.RWMutex - hash []byte - createdAt time.Time -} - -type captureTokenFile struct { - SHA256 string `json:"sha256"` - CreatedAt time.Time `json:"created_at"` -} - -// InitCaptureToken loads the token file if there is one. A missing file is -// the normal first-run state and means "no token": the capture routes stay -// off until one is generated. A file that cannot be read or parsed is -// reported, and likewise leaves the routes off rather than open. -func InitCaptureToken(path string) (*CaptureToken, error) { - t := &CaptureToken{path: path} - - raw, err := os.ReadFile(path) - if errors.Is(err, fs.ErrNotExist) { - return t, nil - } - if err != nil { - return t, fmt.Errorf("reading capture token: %w", err) - } - var stored captureTokenFile - if err := json.Unmarshal(raw, &stored); err != nil { - return t, fmt.Errorf("parsing capture token: %w", err) - } - hash, err := hex.DecodeString(stored.SHA256) - if err != nil || len(hash) != sha256.Size { - return t, fmt.Errorf("capture token file holds no valid hash") - } - t.hash, t.createdAt = hash, stored.CreatedAt - return t, nil -} - -// Generate mints a new token, replacing any existing one, and returns it. -// This is the only moment the token itself exists on the server. -// -// The file is written before the in-memory hash is swapped, so a failed write -// leaves the old token working instead of handing out one that would stop -// working at the next restart. -func (t *CaptureToken) Generate() (string, time.Time, error) { - raw := make([]byte, 32) - if _, err := rand.Read(raw); err != nil { - return "", time.Time{}, err - } - token := hex.EncodeToString(raw) - sum := sha256.Sum256([]byte(token)) - now := time.Now().UTC() - - data, err := json.MarshalIndent(captureTokenFile{SHA256: hex.EncodeToString(sum[:]), CreatedAt: now}, "", " ") - if err != nil { - return "", time.Time{}, err - } - if err := os.MkdirAll(filepath.Dir(t.path), 0755); err != nil { - return "", time.Time{}, fmt.Errorf("creating token directory: %w", err) - } - if err := os.WriteFile(t.path, data, 0600); err != nil { - return "", time.Time{}, fmt.Errorf("writing capture token: %w", err) - } - - t.mu.Lock() - t.hash, t.createdAt = sum[:], now - t.mu.Unlock() - return token, now, nil -} - -// Revoke deletes the token, switching the capture routes off. -func (t *CaptureToken) Revoke() error { - if err := os.Remove(t.path); err != nil && !errors.Is(err, fs.ErrNotExist) { - return fmt.Errorf("removing capture token: %w", err) - } - t.mu.Lock() - t.hash, t.createdAt = nil, time.Time{} - t.mu.Unlock() - return nil -} - -// Status reports whether a token exists and when it was generated. -func (t *CaptureToken) Status() (set bool, createdAt time.Time) { - t.mu.RLock() - defer t.mu.RUnlock() - return t.hash != nil, t.createdAt -} - -// Verify reports whether presented is the current token. With no token it is -// false for every input, the empty string included. -func (t *CaptureToken) Verify(presented string) bool { - t.mu.RLock() - defer t.mu.RUnlock() - if t.hash == nil { - return false - } - sum := sha256.Sum256([]byte(presented)) - return subtle.ConstantTimeCompare(sum[:], t.hash) == 1 -} diff --git a/backend/services/capture_token_test.go b/backend/services/capture_token_test.go deleted file mode 100644 index e38087f..0000000 --- a/backend/services/capture_token_test.go +++ /dev/null @@ -1,126 +0,0 @@ -package services - -import ( - "os" - "path/filepath" - "strings" - "testing" -) - -func newCaptureToken(t *testing.T) (*CaptureToken, string) { - t.Helper() - // A nested path: the token directory may not exist on a fresh checkout. - path := filepath.Join(t.TempDir(), "token", "job_capture_token.json") - tok, err := InitCaptureToken(path) - if err != nil { - t.Fatalf("InitCaptureToken: %v", err) - } - return tok, path -} - -func TestCaptureTokenStartsUnsetAndRejectsEverything(t *testing.T) { - tok, _ := newCaptureToken(t) - if set, _ := tok.Status(); set { - t.Fatal("a fresh store reports a token") - } - // The empty string is the credential of a request with no token at all. - for _, presented := range []string{"", "anything"} { - if tok.Verify(presented) { - t.Fatalf("Verify(%q) passed with no token generated", presented) - } - } -} - -func TestCaptureTokenGenerateVerifyAndRotate(t *testing.T) { - tok, path := newCaptureToken(t) - - first, createdAt, err := tok.Generate() - if err != nil { - t.Fatalf("Generate: %v", err) - } - if len(first) != 64 { - t.Fatalf("token is %d chars, want 64 hex chars (32 bytes)", len(first)) - } - if set, at := tok.Status(); !set || !at.Equal(createdAt) { - t.Fatalf("Status = %v, %v", set, at) - } - if !tok.Verify(first) || tok.Verify(first+"x") || tok.Verify("") { - t.Fatal("Verify does not accept exactly the generated token") - } - - // The file must be useless to someone who reads it, and private anyway. - raw, err := os.ReadFile(path) - if err != nil { - t.Fatalf("reading token file: %v", err) - } - if strings.Contains(string(raw), first) { - t.Fatal("the token itself was written to disk") - } - if info, _ := os.Stat(path); info.Mode().Perm() != 0o600 { - t.Fatalf("token file mode = %v, want 0600", info.Mode().Perm()) - } - - second, _, err := tok.Generate() - if err != nil { - t.Fatalf("Generate: %v", err) - } - if tok.Verify(first) || !tok.Verify(second) { - t.Fatal("generating again must replace the old token") - } -} - -func TestCaptureTokenSurvivesRestart(t *testing.T) { - tok, path := newCaptureToken(t) - token, createdAt, _ := tok.Generate() - - reloaded, err := InitCaptureToken(path) - if err != nil { - t.Fatalf("InitCaptureToken: %v", err) - } - if !reloaded.Verify(token) { - t.Fatal("token no longer verifies after a reload") - } - if _, at := reloaded.Status(); !at.Equal(createdAt) { - t.Fatalf("createdAt = %v, want %v", at, createdAt) - } -} - -func TestCaptureTokenRevoke(t *testing.T) { - tok, path := newCaptureToken(t) - token, _, _ := tok.Generate() - - if err := tok.Revoke(); err != nil { - t.Fatalf("Revoke: %v", err) - } - if tok.Verify(token) { - t.Fatal("token still verifies after Revoke") - } - if _, err := os.Stat(path); !os.IsNotExist(err) { - t.Fatal("token file still exists, so the token would return on restart") - } - if err := tok.Revoke(); err != nil { - t.Fatalf("revoking with nothing to revoke: %v", err) - } -} - -// A damaged file must leave the routes off, never open and never fatal. -func TestCaptureTokenCorruptFile(t *testing.T) { - for name, content := range map[string]string{ - "not json": "{", - "not a hash": `{"sha256": "zz"}`, - "short hash": `{"sha256": "abcd"}`, - "empty object": `{}`, - } { - t.Run(name, func(t *testing.T) { - path := filepath.Join(t.TempDir(), "t.json") - os.WriteFile(path, []byte(content), 0o600) - tok, err := InitCaptureToken(path) - if err == nil { - t.Fatal("expected an error") - } - if tok == nil || tok.Verify("") { - t.Fatal("a corrupt file must yield a usable store that rejects everything") - } - }) - } -} diff --git a/backend/services/database.go b/backend/services/database.go index c328ea2..1dc5f67 100644 --- a/backend/services/database.go +++ b/backend/services/database.go @@ -49,14 +49,8 @@ func migrateDatabase(db *gorm.DB) error { &models.Favorite{}, &models.Rowing{}, &models.Message{}, - &models.JobApplication{}, - &models.JobAppReference{}, &models.Bookmark{}, &models.Place{}, - &models.ProcessedEmail{}, - &models.JobSource{}, - &models.JobLead{}, - &models.JobSearchProfile{}, ) if err != nil { return err diff --git a/backend/services/email_classify_test.go b/backend/services/email_classify_test.go deleted file mode 100644 index 05cdbac..0000000 --- a/backend/services/email_classify_test.go +++ /dev/null @@ -1,185 +0,0 @@ -package services - -import ( - "context" - "encoding/json" - "errors" - "net/http" - "net/http/httptest" - "strings" - "testing" - "unicode/utf8" -) - -// The classify step of the email pipeline: the request the Python service's -// /internal/email/classify receives, and what processEmail does with each -// kind of reply. A stub server stands in for Python. -// -// processEmail is driven only as far as it can go without a database. That -// covers every failure (they all return before the first query) and the two -// "nothing to do" answers; an email that is about a job goes on to look the -// application up, which needs Postgres and is not exercised here. - -func classifierStub(t *testing.T, handler http.HandlerFunc) *EmailSyncService { - t.Helper() - srv := httptest.NewServer(handler) - t.Cleanup(srv.Close) - return &EmailSyncService{PythonURL: srv.URL} -} - -func testEmail() graphMessage { - email := graphMessage{ - ID: "msg-1", - Subject: "Your application to Acme", - ReceivedDateTime: "2026-03-15T10:30:00Z", - Body: graphBody{ContentType: "html", Content: "

Thanks for applying

"}, - } - email.From.EmailAddress = graphEmailAddress{Name: "Acme Hiring", Address: "no-reply@greenhouse.io"} - return email -} - -func TestClassifyEmailRequest(t *testing.T) { - var path string - var body map[string]any - s := classifierStub(t, func(w http.ResponseWriter, r *http.Request) { - path = r.URL.Path - if err := json.NewDecoder(r.Body).Decode(&body); err != nil { - t.Errorf("decoding request: %v", err) - } - w.Write([]byte(`{"isJobEmail": true, "action": "create", "company": "Acme", "jobTitle": "Engineer", - "status": "applied", "location": "London", "url": null, "appliedAt": "2026-03-15", "notes": null}`)) - }) - - analysis, err := s.classifyEmail(context.Background(), testEmail()) - if err != nil { - t.Fatalf("classifyEmail: %v", err) - } - if path != "/internal/email/classify" { - t.Fatalf("path = %q", path) - } - // The whole contract: one key, holding the headers, a blank line and the - // cleaned body. The Python side hands this string to Claude unchanged. - want := "Subject: Your application to Acme\nFrom: Acme Hiring \nDate: 2026-03-15T10:30:00Z\n\nThanks for applying" - if len(body) != 1 || body["message"] != want { - t.Fatalf("request body = %v\nwant message %q", body, want) - } - - if !analysis.IsJobEmail || analysis.Action != "create" || analysis.Company != "Acme" || - analysis.JobTitle != "Engineer" || analysis.Status != "applied" { - t.Fatalf("analysis = %+v", analysis) - } - if analysis.Location == nil || *analysis.Location != "London" || analysis.URL != nil || - analysis.AppliedAt == nil || *analysis.AppliedAt != "2026-03-15" || analysis.Notes != nil { - t.Fatalf("nullable fields = %+v", analysis) - } -} - -func TestProcessEmailWithoutAJob(t *testing.T) { - cases := []struct { - name string - reply string - }{ - // What Python sends for a non-job email: every other field defaulted. - {"not a job email", `{"isJobEmail": false, "action": "", "company": "", "jobTitle": "", "status": "", - "location": null, "url": null, "appliedAt": null, "notes": null}`}, - // (company, job title) is the only key an application has, so an - // answer missing either cannot be matched or created. - {"a job email with no company", `{"isJobEmail": true, "action": "create", "company": "", "jobTitle": "Engineer", "status": "applied"}`}, - {"a job email with no title", `{"isJobEmail": true, "action": "create", "company": "Acme", "jobTitle": "", "status": "applied"}`}, - } - for _, c := range cases { - t.Run(c.name, func(t *testing.T) { - s := classifierStub(t, func(w http.ResponseWriter, r *http.Request) { - w.Write([]byte(c.reply)) - }) - action, jobAppID, err := s.processEmail(context.Background(), testEmail()) - if err != nil || action != "skipped" || jobAppID != nil { - t.Fatalf("processEmail = (%q, %v, %v), want (skipped, nil, nil)", action, jobAppID, err) - } - }) - } -} - -// Every way the classifier can fail must come back from processEmail as an -// error with no action: that is what makes SyncEmails record the email as -// Action "error" with one more attempt used, to be retried next sync. -func TestProcessEmailClassifierFailures(t *testing.T) { - cases := []struct { - name string - status int - body string - wantRelayed string // the 502 detail, when there is one - }{ - {"Claude failed", http.StatusBadGateway, `{"detail": "failed to classify the email"}`, "failed to classify the email"}, - {"Claude's reply was unparseable", http.StatusBadGateway, `{"detail": "failed to parse the email classification"}`, "failed to parse the email classification"}, - {"no API key", http.StatusServiceUnavailable, `{"detail": "CLAUDE_API_KEY is not set"}`, ""}, - {"request rejected", http.StatusUnprocessableEntity, `{"detail": [{"msg": "too long"}]}`, ""}, - {"malformed 200 body", http.StatusOK, `not json`, ""}, - {"200 body of the wrong shape", http.StatusOK, `{"isJobEmail": "yes"}`, ""}, - } - for _, c := range cases { - t.Run(c.name, func(t *testing.T) { - s := classifierStub(t, func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(c.status) - w.Write([]byte(c.body)) - }) - action, jobAppID, err := s.processEmail(context.Background(), testEmail()) - if err == nil { - t.Fatal("expected an error") - } - if action != "" || jobAppID != nil { - t.Fatalf("processEmail = (%q, %v) alongside an error", action, jobAppID) - } - // Not a cancellation: SyncEmails skips those without recording - // anything, which would leave a real failure retried for ever. - if errors.Is(err, context.Canceled) { - t.Fatalf("err = %v reads as a cancelled sync", err) - } - var pyErr *PythonError - if errors.As(err, &pyErr) != (c.wantRelayed != "") { - t.Fatalf("err = %v, want PythonError: %v", err, c.wantRelayed != "") - } - if pyErr != nil && pyErr.Detail != c.wantRelayed { - t.Fatalf("detail = %q, want %q", pyErr.Detail, c.wantRelayed) - } - }) - } -} - -// The other half of the rule above: a sync abandoned mid-call (the admin -// closed the tab) must be recognisable, so the email's attempts do not advance. -func TestProcessEmailCancelled(t *testing.T) { - s := classifierStub(t, func(http.ResponseWriter, *http.Request) {}) - ctx, cancel := context.WithCancel(context.Background()) - cancel() - if _, _, err := s.processEmail(ctx, testEmail()); !errors.Is(err, context.Canceled) { - t.Fatalf("err = %v, want it to wrap context.Canceled", err) - } -} - -func TestClassifierMessageIsCapped(t *testing.T) { - // An ordinary email is nowhere near the cap and is not touched. - if got := classifierMessage(testEmail()); !strings.HasSuffix(got, "\n\nThanks for applying") { - t.Fatalf("message = %q", got) - } - - // cleanEmailBody bounds the body, so only the headers can push a message - // over. Multi-byte runes: the cap counts characters, as the Python side - // does, and the cut must not split one. - long := testEmail() - long.Subject = strings.Repeat("é", maxClassifyRunes+50) - got := classifierMessage(long) - if n := utf8.RuneCountInString(got); n != maxClassifyRunes { - t.Fatalf("message is %d runes, want %d", n, maxClassifyRunes) - } - if !utf8.ValidString(got) { - t.Fatal("the cut split a rune") - } - - // More bytes than the cap but fewer runes: within the limit, so intact. - wide := testEmail() - wide.Subject = strings.Repeat("é", maxClassifyRunes/2+10) - if got := classifierMessage(wide); !strings.HasSuffix(got, "\n\nThanks for applying") { - t.Fatal("a message under the rune cap was cut") - } -} diff --git a/backend/services/email_imap.go b/backend/services/email_imap.go deleted file mode 100644 index 88dd61f..0000000 --- a/backend/services/email_imap.go +++ /dev/null @@ -1,420 +0,0 @@ -package services - -import ( - "bufio" - "crypto/sha256" - "crypto/tls" - "encoding/hex" - "fmt" - "io" - "log" - "mime" - "mime/multipart" - "net" - "net/mail" - "strings" - "sync/atomic" - "time" -) - -// This file is a hand-rolled IMAP client, used as an alternative mail source -// to Microsoft Graph. It exists because the Graph path needs an Azure app -// registration and admin consent, while IMAP needs only an app password. -// -// It implements the bare minimum of RFC 3501 — LOGIN, SELECT, SEARCH, FETCH, -// LOGOUT — by matching on string prefixes rather than parsing IMAP's grammar -// properly. It works against Outlook and similar servers with the response -// shapes seen in practice; it is not a general-purpose IMAP client. - -// IMAPConfig holds the mailbox credentials. Password is an app password, not -// an account password. -type IMAPConfig struct { - Host string - Port string - Email string - Password string -} - -// imapClient is a minimal, lenient IMAP client that tolerates -// Outlook's non-standard response formatting. -type imapClient struct { - conn net.Conn - reader *bufio.Reader - // tag numbers the commands. IMAP allows several in flight at once - // identified by tag; this client never does that, so the atomic is - // belt-and-braces rather than load-bearing. - tag atomic.Int64 -} - -// imapDial opens an implicit-TLS IMAP connection (port 993 style, TLS from the -// first byte — there is no STARTTLS support here) and consumes the server -// greeting, which arrives unsolicited before any command. -func imapDial(addr string) (*imapClient, error) { - conn, err := tls.Dial("tcp", addr, nil) - if err != nil { - return nil, err - } - c := &imapClient{ - conn: conn, - reader: bufio.NewReader(conn), - } - // Read server greeting - if _, err := c.readLine(); err != nil { - conn.Close() - return nil, fmt.Errorf("reading greeting: %w", err) - } - return c, nil -} - -// Close drops the TCP connection. Callers normally send LOGOUT first. -func (c *imapClient) Close() error { - return c.conn.Close() -} - -// nextTag returns the next command tag, e.g. "A0001". The width is cosmetic: -// past 9999 the tags simply get longer, and they stay unique. -func (c *imapClient) nextTag() string { - return fmt.Sprintf("A%04d", c.tag.Add(1)) -} - -// readLine reads one CRLF-terminated protocol line with the terminator -// stripped. There is no read deadline anywhere in this client, so an -// unresponsive server can block a sync until the TCP connection itself fails. -func (c *imapClient) readLine() (string, error) { - line, err := c.reader.ReadString('\n') - return strings.TrimRight(line, "\r\n"), err -} - -// sendCommand sends a tagged command and reads lines until the line beginning -// with that tag, which is the server's final status for the command. -// Everything before it is an untagged ("* ...") response and is returned. -// -// This must not be used for FETCH: it reads line by line and would mistake the -// bytes of a literal for protocol lines. Use sendFetch instead. -func (c *imapClient) sendCommand(cmd string) (untagged []string, status string, err error) { - tag := c.nextTag() - _, err = fmt.Fprintf(c.conn, "%s %s\r\n", tag, cmd) - if err != nil { - return nil, "", err - } - - for { - line, err := c.readLine() - if err != nil { - return untagged, "", err - } - if strings.HasPrefix(line, tag+" ") { - return untagged, line, nil - } - untagged = append(untagged, line) - } -} - -// sendCommandOK sends a command and returns an error if the response is not OK. -func (c *imapClient) sendCommandOK(cmd string) ([]string, error) { - untagged, status, err := c.sendCommand(cmd) - if err != nil { - return untagged, err - } - // Status line is " OK ..." on success, " NO ..." or - // " BAD ..." otherwise; only the second field matters. - parts := strings.SplitN(status, " ", 3) - if len(parts) < 2 || parts[1] != "OK" { - return untagged, fmt.Errorf("command %q failed: %s", cmd, status) - } - return untagged, nil -} - -// readLiteral reads exactly size bytes of an IMAP literal, i.e. the payload -// announced by a trailing "{N}" on the preceding line. It must read by byte -// count rather than by line because the payload is arbitrary binary data that -// will itself contain CRLFs. -func (c *imapClient) readLiteral(size int) (string, error) { - buf := make([]byte, size) - _, err := io.ReadFull(c.reader, buf) - if err != nil { - return "", err - } - return string(buf), nil -} - -// fetchPart is one FETCH response line plus the literal payload that followed -// it, if any. Pairing them in the type removes the need for callers to walk an -// interleaved slice and manually skip every second entry — the previous shape, -// where a literal was simply the next element and a caller that forgot to -// advance would parse message bytes as a protocol line. -type fetchPart struct { - Line string - // Literal is the payload that followed Line, valid only when HasLiteral. - Literal string - HasLiteral bool -} - -// sendFetch sends a FETCH and collects its response, handling literals. -// -// The literal is detected with LastIndex("{") plus a "}" suffix rather than a -// real parse, so a line whose text merely ends in braces could be misread — -// tolerable because only FETCH responses reach this code. -func (c *imapClient) sendFetch(cmd string) ([]fetchPart, error) { - tag := c.nextTag() - _, err := fmt.Fprintf(c.conn, "%s %s\r\n", tag, cmd) - if err != nil { - return nil, err - } - - var parts []fetchPart - for { - line, err := c.readLine() - if err != nil { - return parts, err - } - - // Check for literal marker {N} at end of line - if idx := strings.LastIndex(line, "{"); idx >= 0 && strings.HasSuffix(line, "}") { - sizeStr := line[idx+1 : len(line)-1] - var size int - if _, err := fmt.Sscanf(sizeStr, "%d", &size); err == nil && size > 0 { - literal, err := c.readLiteral(size) - if err != nil { - return parts, fmt.Errorf("reading literal of %d bytes: %w", size, err) - } - parts = append(parts, fetchPart{Line: line, Literal: literal, HasLiteral: true}) - continue - } - } - - if strings.HasPrefix(line, tag+" ") { - // Check for OK - fields := strings.SplitN(line, " ", 3) - if len(fields) >= 2 && fields[1] != "OK" { - return parts, fmt.Errorf("FETCH failed: %s", line) - } - return parts, nil - } - parts = append(parts, fetchPart{Line: line}) - } -} - -// fetchEmailsIMAP connects to an IMAP server and retrieves emails since the given time. -func (s *EmailSyncService) fetchEmailsIMAP(since time.Time) ([]graphMessage, error) { - addr := fmt.Sprintf("%s:%s", s.Config.IMAP.Host, s.Config.IMAP.Port) - - c, err := imapDial(addr) - if err != nil { - return nil, fmt.Errorf("IMAP connect: %w", err) - } - defer c.Close() - - // %q wraps the password in double quotes and backslash-escapes any quote - // or backslash inside it, which happens to be exactly IMAP's quoted-string - // syntax. The username is NOT quoted: an address needs no escaping. - // Note this sends the password in a LOGIN command, so it is only safe - // because the connection is TLS from the first byte. - quotedPass := fmt.Sprintf("%q", s.Config.IMAP.Password) - if _, err := c.sendCommandOK(fmt.Sprintf("LOGIN %s %s", s.Config.IMAP.Email, quotedPass)); err != nil { - return nil, fmt.Errorf("IMAP login: %w", err) - } - - if _, err := c.sendCommandOK("SELECT INBOX"); err != nil { - return nil, fmt.Errorf("IMAP select INBOX: %w", err) - } - - // SEARCH SINCE has day granularity only — the time of day is not - // expressible — so this always over-fetches back to midnight of `since`. - // Harmless: SyncEmails deduplicates by message id. The date must be in - // IMAP's dd-Mon-yyyy form, hence this exact layout string. - dateStr := since.UTC().Format("02-Jan-2006") - untagged, err := c.sendCommandOK(fmt.Sprintf("SEARCH SINCE %s", dateStr)) - if err != nil { - return nil, fmt.Errorf("IMAP search: %w", err) - } - - // Parse sequence numbers from "* SEARCH 1 2 3 ...". parts[2:] skips the - // "*" and "SEARCH" tokens; a bare "* SEARCH" (no matches) has len 2 and - // is skipped by the length test. - var seqNums []string - for _, line := range untagged { - if strings.HasPrefix(line, "* SEARCH") { - parts := strings.Fields(line) - if len(parts) > 2 { - seqNums = append(seqNums, parts[2:]...) - } - } - } - - if len(seqNums) == 0 { - log.Printf("[EmailSync/IMAP] No messages found since %s", dateStr) - c.sendCommand("LOGOUT") - return nil, nil - } - - log.Printf("[EmailSync/IMAP] Found %d messages since %s", len(seqNums), dateStr) - - // Every matching message is fetched in one command with a comma-separated - // sequence set, and each full body is held in memory. A mailbox with a - // very busy day could make this large — there is no batching. - seqSet := strings.Join(seqNums, ",") - fetchParts, err := c.sendFetch(fmt.Sprintf("FETCH %s (BODY[])", seqSet)) - if err != nil { - return nil, fmt.Errorf("IMAP fetch: %w", err) - } - - // Each body arrives as a "... BODY[] {N}" line carrying its literal, so - // the pairing is now part of the value rather than something this loop has - // to reconstruct by skipping entries. A message that fails to parse is - // logged and skipped rather than failing the whole sync. - var messages []graphMessage - for _, part := range fetchParts { - if part.HasLiteral && strings.Contains(part.Line, "BODY[]") { - gm, err := parseRawEmail(part.Literal) - if err != nil { - log.Printf("[EmailSync/IMAP] Error parsing email: %v", err) - continue - } - messages = append(messages, gm) - } - } - - // LOGOUT errors are ignored: the emails are already in hand and the - // deferred Close will drop the connection regardless. - c.sendCommand("LOGOUT") - return messages, nil -} - -// parseRawEmail parses a raw RFC822 message into the same graphMessage struct -// the Graph API path produces, so everything downstream is source-agnostic. -// An unparseable Date falls back to now, and a missing From leaves both name -// and address empty rather than failing. -func parseRawEmail(raw string) (graphMessage, error) { - msg, err := mail.ReadMessage(strings.NewReader(raw)) - if err != nil { - return graphMessage{}, fmt.Errorf("parsing message: %w", err) - } - - header := msg.Header - - // Parse From - var fromName, fromAddr string - if fromList, err := header.AddressList("From"); err == nil && len(fromList) > 0 { - fromName = fromList[0].Name - fromAddr = fromList[0].Address - } - - // Parse Date - dateStr := header.Get("Date") - parsedDate, err := mail.ParseDate(dateStr) - if err != nil { - parsedDate = time.Now() - } - - // Extract body text - bodyContent := extractTextBody(msg.Header, msg.Body) - - // Dedup is keyed on GraphMessageID: a missing Message-ID header would - // yield "", which collides every headerless message onto one shared row - // (the first one processed, forever). Synthesise an id from stable - // message traits instead — hashing because From/Date/Subject/size are not - // unique alone but their combination is stable across retries. - msgID := header.Get("Message-ID") - if msgID == "" { - hash := sha256.Sum256([]byte(fromAddr + "|" + dateStr + "|" + header.Get("Subject") + "|" + bodyContent)) - msgID = "synth-" + hex.EncodeToString(hash[:8]) - } - - return graphMessage{ - ID: msgID, - Subject: decodeHeader(header.Get("Subject")), - ReceivedDateTime: parsedDate.Format(time.RFC3339), - From: graphFrom{ - EmailAddress: graphEmailAddress{ - Name: fromName, - Address: fromAddr, - }, - }, - Body: graphBody{ - ContentType: "text", - Content: bodyContent, - }, - }, nil -} - -// extractTextBody pulls readable content out of a message body, preferring -// text/plain and falling back to text/html. -// -// It recurses into nested multipart parts by re-wrapping the part's bytes in a -// synthetic mail.Header carrying just its Content-Type — a shortcut that works -// because this function only ever reads Content-Type. -// -// Quoted-printable and base64 transfer encodings are NOT decoded, so a -// base64-encoded body reaches Claude as base64. Read errors on a part are -// swallowed and the part is skipped. -func extractTextBody(header mail.Header, body io.Reader) string { - contentType := header.Get("Content-Type") - if contentType == "" { - contentType = "text/plain" - } - - mediaType, params, err := mime.ParseMediaType(contentType) - if err != nil { - // Try reading as plain text - b, _ := io.ReadAll(body) - return string(b) - } - - if strings.HasPrefix(mediaType, "multipart/") { - boundary := params["boundary"] - if boundary == "" { - b, _ := io.ReadAll(body) - return string(b) - } - - mr := multipart.NewReader(body, boundary) - var textContent, htmlContent string - for { - part, err := mr.NextPart() - if err != nil { - break - } - partType := part.Header.Get("Content-Type") - partMedia, _, _ := mime.ParseMediaType(partType) - b, err := io.ReadAll(part) - if err != nil { - continue - } - switch partMedia { - case "text/plain": - textContent = string(b) - case "text/html": - htmlContent = string(b) - case "multipart/alternative", "multipart/related", "multipart/mixed": - // Recursively handle nested multipart - nested := extractTextBody( - mail.Header{"Content-Type": {partType}}, - strings.NewReader(string(b)), - ) - if nested != "" && textContent == "" { - textContent = nested - } - } - } - if textContent != "" { - return textContent - } - return htmlContent - } - - b, _ := io.ReadAll(body) - return string(b) -} - -// decodeHeader decodes RFC 2047 encoded-words (the "=?UTF-8?Q?...?=" form -// used for non-ASCII subjects), returning the input unchanged if it is not -// encoded or cannot be decoded. -func decodeHeader(s string) string { - dec := new(mime.WordDecoder) - decoded, err := dec.DecodeHeader(s) - if err != nil { - return s - } - return decoded -} diff --git a/backend/services/email_status_test.go b/backend/services/email_status_test.go deleted file mode 100644 index 1d2825b..0000000 --- a/backend/services/email_status_test.go +++ /dev/null @@ -1,97 +0,0 @@ -package services - -import "testing" - -// These tests cover the status progression rule only — StatusAdvances, the -// predicate extracted out of updateJobApplication. The rest of -// updateJobApplication (note appending, the DB.Save, the returned counters) -// needs a live *gorm.DB and the only driver in go.mod is postgres, so it is -// deliberately not exercised here. Nothing in this file touches the classifier -// or the Graph API either; see email_classify_test.go for the former. - -func TestStatusAdvances(t *testing.T) { - cases := []struct { - name string - current string - next string - want bool - }{ - {"one step forward is the normal case", "applied", "screening", true}, - {"skipping intermediate stages still advances", "applied", "offer", true}, - {"adjacent step backwards is refused", "interviewing", "assessment", false}, - {"a long way backwards is refused", "offer", "applied", false}, - {"same status is not progression, so a duplicate email is a no-op", "screening", "screening", false}, - - // rejected and withdrawn sit at the top of statusOrder: once an - // application lands there, no later email may move it. - {"rejected cannot fall back to interviewing", "rejected", "interviewing", false}, - {"rejected cannot fall back to offer", "rejected", "offer", false}, - {"rejected cannot repeat", "rejected", "rejected", false}, - {"withdrawn cannot fall back to offer", "withdrawn", "offer", false}, - {"withdrawn cannot fall back to rejected", "withdrawn", "rejected", false}, - {"withdrawn cannot repeat", "withdrawn", "withdrawn", false}, - // The one ordering asymmetry between the two terminals: withdrawn - // ranks above rejected, so this single pair is allowed. - {"rejected may still become withdrawn because withdrawn ranks higher", "rejected", "withdrawn", true}, - - // saved is a browser capture that has not been applied to yet. - {"a saved posting advances once the application is confirmed", "saved", "applied", true}, - {"an applied row cannot fall back to saved", "applied", "saved", false}, - - {"an unknown new status is never applied", "applied", "hired", false}, - {"an empty new status is never applied", "applied", "", false}, - {"an unknown new status cannot escape a terminal state either", "rejected", "ghosted", false}, - {"a recognised status takes over from an unknown current status", "ghosted", "applied", true}, - {"a recognised status takes over from an empty current status", "", "offer", true}, - {"unknown to unknown stays put", "ghosted", "hired", false}, - } - for _, c := range cases { - t.Run(c.name, func(t *testing.T) { - if got := StatusAdvances(c.current, c.next); got != c.want { - t.Errorf("StatusAdvances(%q, %q) = %v, want %v", c.current, c.next, got, c.want) - } - }) - } -} - -// Guards the claim the other tests rest on: rejected and withdrawn really are -// the top of the ranking, so adding a stage below them cannot silently make -// them non-terminal. -func TestTerminalStatusesRankHighest(t *testing.T) { - for status, order := range statusOrder { - if status == "rejected" || status == "withdrawn" { - continue - } - if order >= statusOrder["rejected"] { - t.Errorf("%q ranks %d, at or above rejected (%d)", status, order, statusOrder["rejected"]) - } - } -} - -// NormalizeStatus is the guard that keeps Claude's occasional casing drift -// ("Interview", "on hold") out of the status column: an unrecognised value -// stored verbatim makes StatusAdvances treat the row's current status as -// unknown, which switches the forward-only rule off for that row entirely. -func TestNormalizeStatus(t *testing.T) { - cases := []struct { - name string - in string - want string - }{ - {"a tracked status passes through", "interviewing", "interviewing"}, - {"saved is tracked, so a capture keeps it", "saved", "saved"}, - {"casing drift is lowered, not rejected", "Interviewing", "interviewing"}, - {"surrounding whitespace is trimmed", " offer ", "offer"}, - {"an untracked status falls back to the pipeline default", "on hold", "applied"}, - {"the UI's old Title Case value is recognised once lowered", "Rejected", "rejected"}, - {"a value the UI once allowed but the pipeline never had is rejected", "Interview", "applied"}, - {"empty falls back rather than storing a blank status", "", "applied"}, - } - for _, c := range cases { - t.Run(c.name, func(t *testing.T) { - if got := NormalizeStatus(c.in); got != c.want { - t.Errorf("NormalizeStatus(%q) = %q, want %q", c.in, got, c.want) - } - }) - } -} diff --git a/backend/services/email_sync.go b/backend/services/email_sync.go deleted file mode 100644 index 618b81f..0000000 --- a/backend/services/email_sync.go +++ /dev/null @@ -1,994 +0,0 @@ -package services - -import ( - "context" - "encoding/json" - "errors" - "fmt" - "io" - "log" - "net/http" - "net/url" - "os" - "path/filepath" - "regexp" - "strings" - "sync" - "time" - - "adam-french.co.uk/backend/models" - "golang.org/x/oauth2" - "gorm.io/gorm" -) - -// This file is the job-application email pipeline. On a timer it fetches -// recent mail (via Microsoft Graph or plain IMAP), keeps the ones that look -// recruitment-related, asks Claude to turn each into structured data, and -// creates or advances a models.JobApplication row. Every email it has looked -// at is recorded as a models.ProcessedEmail so it is never handled twice. -// -// The Claude call itself is not made here: like the site's other two, it -// lives in the Python service (python/app/email_classify.py, which owns the -// prompt and the parsing of the model's reply) and is reached through -// CallPython. Everything that needs the mailbox or the database — fetching, -// the pre-filter, dedup and retry accounting, matching an email to an -// application, the forward-only status rule — stays in this file. - -// MSGRAPH_TOKEN_JSON_PATH lives in a Docker volume so the OAuth refresh token -// survives restarts, exactly like the Spotify token. -const MSGRAPH_TOKEN_JSON_PATH = "/backend/token/msgraph_token.json" - -// EmailSyncConfig configures the pipeline. Backend picks the mail source; -// anything other than "graph" or "imap" leaves the service permanently idle. -type EmailSyncConfig struct { - Backend string // "graph" or "imap" - ClientID string - ClientSecret string - TenantID string - RedirectURI string - IMAP *IMAPConfig - SyncInterval time.Duration - Enabled bool -} - -// EmailSyncService owns the sync pipeline. -type EmailSyncService struct { - Config *EmailSyncConfig - OAuthConfig *oauth2.Config - // HTTPClient doubles as the readiness flag: nil means "not configured or - // not yet authenticated", and both the scheduler and the manual-trigger - // handler refuse to run while it is nil. On the Graph backend it is a - // real token-injecting client; on the IMAP backend it is set to - // http.DefaultClient purely so this check passes (IMAP never uses it). - HTTPClient *http.Client - DB *gorm.DB - // PythonURL is the Python service's base URL on the Docker network, no - // trailing slash: the same value as handlers.Store.PythonURL. The - // classifier is called there (see classifyEmail). - PythonURL string - // mu is used with TryLock, not Lock: it makes a sync a no-op while - // another one is running rather than queueing behind it, so the manual - // admin trigger cannot pile up on top of the scheduled run. - mu sync.Mutex -} - -// Microsoft Graph API response types - -// Microsoft Graph API response types. The IMAP backend parses raw RFC822 -// messages into these same structs (see parseRawEmail) so that everything -// downstream of fetchEmails is backend-agnostic. - -// graphMessagesResponse is one page of /me/messages; NextLink is Graph's -// cursor for the next page and is empty on the last one. -type graphMessagesResponse struct { - Value []graphMessage `json:"value"` - NextLink string `json:"@odata.nextLink"` -} - -// graphMessage is a single email. -type graphMessage struct { - ID string `json:"id"` - Subject string `json:"subject"` - ReceivedDateTime string `json:"receivedDateTime"` - From graphFrom `json:"from"` - Body graphBody `json:"body"` - BodyPreview string `json:"bodyPreview"` -} - -// graphFrom wraps the sender, which Graph nests one level deep. -type graphFrom struct { - EmailAddress graphEmailAddress `json:"emailAddress"` -} - -// graphEmailAddress is a display name plus address. -type graphEmailAddress struct { - Name string `json:"name"` - Address string `json:"address"` -} - -// graphBody is the message body; ContentType is "html" or "text". -type graphBody struct { - ContentType string `json:"contentType"` - Content string `json:"content"` -} - -// Classifier response type - -// EmailAnalysis is the JSON contract with the Python service's -// /internal/email/classify: the body of its 200 reply. The keys here must stay -// in step with EmailAnalysis and the prompt in python/app/email_classify.py, -// which asks Claude for exactly these. Pointer fields are the ones that may -// come back null; the plain strings come back "" when the model had nothing -// (or when the email is not a job email, in which case only IsJobEmail means -// anything). -type EmailAnalysis struct { - IsJobEmail bool `json:"isJobEmail"` - Action string `json:"action"` - Company string `json:"company"` - JobTitle string `json:"jobTitle"` - Status string `json:"status"` - Location *string `json:"location"` - URL *string `json:"url"` - AppliedAt *string `json:"appliedAt"` - Notes *string `json:"notes"` -} - -// Email filtering config - -// Cheap pre-filter, applied before any classifier call so that the bulk of a -// mailbox never costs an API request. It is intentionally over-inclusive: -// false positives are cheap (Claude rejects them), false negatives are not -// (the email is never looked at again once its window has passed). - -// subjectKeywords match case-insensitively anywhere in the subject line. -var subjectKeywords = []string{ - "application", "interview", "offer", "rejected", "assessment", - "applied", "candidate", "position", "role", "hiring", - "thank you for applying", "we regret", "move forward", - "next steps", "coding challenge", "take-home", -} - -// senderDomains are applicant-tracking systems; mail from any of them is -// considered job-related whatever the subject says. -var senderDomains = []string{ - "greenhouse.io", "lever.co", "workday.com", "myworkday.com", - "ashbyhq.com", "smartrecruiters.com", "icims.com", - "jobvite.com", "taleo.net", "breezy.hr", "recruitee.com", - "applytojob.com", "jazz.co", "dover.com", -} - -// Status progression order - -// statusOrder ranks the application lifecycle so updates can only move an -// application forwards (see updateJobApplication). 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" is the one status no email can produce: it marks a posting captured -// from the browser but not applied to yet (handlers/handle_job_capture.go). -// It ranks lowest so that the "thanks for applying" email advances the row. -// -// This map is the vocabulary. It is written down in four other places, which -// must list the same statuses: `enum JobStatus` in -// graph/schema/job_application.graphql (enforced — -// TestJobStatusEnumMatchesStatusOrder fails on any difference), the -// classifier prompt in python/app/email_classify.py (all but "saved"), the -// tracker page and the capture userscript. -var statusOrder = map[string]int{ - "saved": 0, - "applied": 1, - "screening": 2, - "assessment": 3, - "interviewing": 4, - "offer": 5, - "rejected": 6, - "withdrawn": 7, -} - -// Token persistence - -// SaveMSGraphToken persists an OAuth token to disk with 0600 permissions. -// Like the Spotify equivalent it copies into a local struct so the on-disk -// shape does not depend on the oauth2 package's own JSON tags. -func SaveMSGraphToken(path string, tok *oauth2.Token) error { - data := struct { - AccessToken string `json:"access_token"` - RefreshToken string `json:"refresh_token"` - TokenType string `json:"token_type"` - Expiry time.Time `json:"expiry"` - }{ - AccessToken: tok.AccessToken, - RefreshToken: tok.RefreshToken, - TokenType: tok.TokenType, - Expiry: tok.Expiry, - } - - if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil { - return fmt.Errorf("creating token directory: %w", err) - } - - jsonBytes, err := json.MarshalIndent(data, "", " ") - if err != nil { - return err - } - - return os.WriteFile(path, jsonBytes, 0600) -} - -// LoadMSGraphToken reads a token written by SaveMSGraphToken. A missing file -// is reported as an error and means "not yet authenticated". -func LoadMSGraphToken(path string) (*oauth2.Token, error) { - data, err := os.ReadFile(path) - if err != nil { - return nil, err - } - - var saved struct { - AccessToken string `json:"access_token"` - RefreshToken string `json:"refresh_token"` - TokenType string `json:"token_type"` - Expiry time.Time `json:"expiry"` - } - - if err := json.Unmarshal(data, &saved); err != nil { - return nil, err - } - - return &oauth2.Token{ - AccessToken: saved.AccessToken, - RefreshToken: saved.RefreshToken, - TokenType: saved.TokenType, - Expiry: saved.Expiry, - }, nil -} - -// persistingTokenSource wraps an oauth2.TokenSource to save refreshed tokens to disk. -type persistingTokenSource struct { - base oauth2.TokenSource - path string - lastToken *oauth2.Token -} - -// Token returns a valid token, refreshing through the wrapped source when -// needed and writing any new token back to disk. -// -// Without this wrapper the oauth2 client would refresh happily in memory but -// the file on disk would keep the original refresh token; Microsoft rotates -// refresh tokens, so after the original expired the service would have to be -// re-authorised by hand on the next restart. -// -// There is no mutex here even though oauth2's client may call Token from -// several goroutines. In practice syncs are serialised by EmailSyncService.mu -// so concurrent calls do not arise; the worst case if they ever did is a -// duplicate write of the same token. -func (p *persistingTokenSource) Token() (*oauth2.Token, error) { - tok, err := p.base.Token() - if err != nil { - return nil, err - } - // Save only when the token actually changed (i.e. was refreshed) - if p.lastToken == nil || tok.AccessToken != p.lastToken.AccessToken { - p.lastToken = tok - if saveErr := SaveMSGraphToken(p.path, tok); saveErr != nil { - log.Printf("[EmailSync] Warning: failed to persist refreshed token: %v", saveErr) - } - } - return tok, nil -} - -// InitEmailSync builds the service and, for the Graph backend, restores a -// saved OAuth session. It never fails: a misconfigured or unauthenticated -// service is returned with a nil HTTPClient, which leaves the pipeline idle -// while the rest of the backend starts normally. For Graph, the authorisation -// URL is printed to the container log for a one-off manual sign-in that -// lands on GET /email/callback. -// -// pythonURL is where the classifier lives. It is not validated or probed: an -// unreachable Python service shows up as each email failing and being -// retried, the same way a bad API key used to. -func InitEmailSync(config *EmailSyncConfig, db *gorm.DB, pythonURL string) *EmailSyncService { - svc := &EmailSyncService{ - Config: config, - DB: db, - PythonURL: pythonURL, - } - - switch config.Backend { - case "imap": - if config.IMAP == nil || config.IMAP.Email == "" { - log.Println("[EmailSync] IMAP backend selected but not configured") - return svc - } - // IMAP connects per-sync, no persistent client needed. - // Mark as ready by setting a non-nil HTTPClient (used as readiness flag). - svc.HTTPClient = http.DefaultClient - log.Printf("[EmailSync] Configured with IMAP backend (%s)", config.IMAP.Host) - - case "graph": - oauthConfig := &oauth2.Config{ - ClientID: config.ClientID, - ClientSecret: config.ClientSecret, - Endpoint: oauth2.Endpoint{ - AuthURL: fmt.Sprintf("https://login.microsoftonline.com/%s/oauth2/v2.0/authorize", config.TenantID), - TokenURL: fmt.Sprintf("https://login.microsoftonline.com/%s/oauth2/v2.0/token", config.TenantID), - }, - RedirectURL: config.RedirectURI, - Scopes: []string{"https://graph.microsoft.com/Mail.Read", "offline_access"}, - } - svc.OAuthConfig = oauthConfig - - token, err := LoadMSGraphToken(MSGRAPH_TOKEN_JSON_PATH) - if err != nil || token == nil { - authURL := oauthConfig.AuthCodeURL("state", oauth2.AccessTypeOffline) - log.Println("[EmailSync] No token saved. Authenticate Microsoft Graph with:") - log.Println(authURL) - return svc - } - - baseSource := oauthConfig.TokenSource(context.Background(), token) - persistSource := &persistingTokenSource{base: baseSource, path: MSGRAPH_TOKEN_JSON_PATH, lastToken: token} - svc.HTTPClient = oauth2.NewClient(context.Background(), persistSource) - log.Println("[EmailSync] Authenticated with Microsoft Graph") - - default: - log.Printf("[EmailSync] Unknown backend %q, defaulting to disabled", config.Backend) - } - - return svc -} - -// AuthURL returns the OAuth2 authorization URL for initial setup. -func (s *EmailSyncService) AuthURL() string { - return s.OAuthConfig.AuthCodeURL("state", oauth2.AccessTypeOffline) -} - -// CompleteAuth exchanges an authorization code for a token and initializes the HTTP client. -func (s *EmailSyncService) CompleteAuth(ctx context.Context, code string) error { - token, err := s.OAuthConfig.Exchange(ctx, code) - if err != nil { - return fmt.Errorf("token exchange failed: %w", err) - } - - if err := SaveMSGraphToken(MSGRAPH_TOKEN_JSON_PATH, token); err != nil { - return fmt.Errorf("saving token: %w", err) - } - - baseSource := s.OAuthConfig.TokenSource(ctx, token) - persistSource := &persistingTokenSource{base: baseSource, path: MSGRAPH_TOKEN_JSON_PATH, lastToken: token} - s.HTTPClient = oauth2.NewClient(ctx, persistSource) - - log.Println("[EmailSync] Authentication completed successfully") - return nil -} - -// StartScheduler runs SyncEmails immediately and then on every tick until ctx -// is cancelled. It is meant to be run in its own goroutine and returns -// straight away when the service is disabled or unauthenticated. -// -// Because readiness is only checked once here, authenticating later via -// /email/callback does NOT start the scheduler; the backend has to be -// restarted, or syncs triggered by hand through POST /email/sync. -func (s *EmailSyncService) StartScheduler(ctx context.Context) { - if !s.Config.Enabled { - log.Println("[EmailSync] Disabled, skipping scheduler") - return - } - if s.HTTPClient == nil { - log.Println("[EmailSync] Not authenticated, skipping scheduler") - return - } - - log.Printf("[EmailSync] Starting scheduler, interval: %s", s.Config.SyncInterval) - - // Run once immediately on startup - if err := s.SyncEmails(ctx); err != nil { - log.Printf("[EmailSync] Initial sync error: %v", err) - } - - ticker := time.NewTicker(s.Config.SyncInterval) - defer ticker.Stop() - - for { - select { - case <-ctx.Done(): - log.Println("[EmailSync] Scheduler stopped") - return - case <-ticker.C: - if err := s.SyncEmails(ctx); err != nil { - log.Printf("[EmailSync] Sync error: %v", err) - } - } - } -} - -// SyncEmails is the main pipeline: fetch, filter, dedup, classify, create/update. -func (s *EmailSyncService) SyncEmails(ctx context.Context) error { - // TryLock, so a manual trigger during a scheduled run is rejected - // immediately instead of blocking a request for minutes. - if !s.mu.TryLock() { - return fmt.Errorf("sync already in progress") - } - defer s.mu.Unlock() - - // Registered after the unlock defer, therefore it runs BEFORE it: the - // panic is absorbed here and the mutex is still released afterwards. - // A recovered panic makes SyncEmails return nil, so the caller sees a - // successful sync — the log line is the only evidence. - defer func() { - if r := recover(); r != nil { - log.Printf("[EmailSync] PANIC recovered: %v", r) - } - }() - - log.Println("[EmailSync] Starting sync...") - - // Window start comes from the newest email we have ever *received* (one of - // two clocks in play) rather than from when we processed it: receive time - // lags processing time by up to one sync duration, and a later window - // anchored to processing time would start AFTER mail that arrived just at - // the previous fetch — a permanent hole (the overlap the code always meant - // to have is produced only when both edges speak the same clock). - // Anchoring on ReceivedAt keeps the window behind the fetch, the - // ProcessedEmail dedup absorbs the deliberate re-fetch overlap, and on a - // cold database it falls back to the last 24 hours so the pipeline never - // tries to ingest an entire mailbox. - since := time.Now().Add(-24 * time.Hour) - var latest models.ProcessedEmail - if err := s.DB.Where("received_at > ?", time.Time{}).Order("received_at DESC").First(&latest).Error; err == nil { - // Pull the window back one slack period so mail delivered a second or - // two after the last fetch (or indexed late by the provider) is still - // inside the next window; dedup makes re-processing it harmless. - since = latest.ReceivedAt.Add(-fetchSlack) - } - - // Pull the window back to cover any still-retryable failure. Without this - // the clamp above would have advanced past a failed email — the error row - // is written now, so the next window starts after it — and the retry - // below could never see the email again. Rows predating ReceivedAt have - // a zero value and are ignored rather than dragging the window to 0001. - // - // Old failures are age-capped: attempts only advance when the email is - // actually re-fetched, so a message that has left the mailbox would stay - // under the cap forever and rewind every sync on this day's fetch. After - // maxRewindAge the email is treated as gone, like any abandoned retry. - var oldestRetryable models.ProcessedEmail - if err := s.DB. - Where("action = ? AND attempts < ? AND received_at > ? AND received_at > ?", - "error", maxEmailAttempts, time.Time{}, time.Now().Add(-maxRewindAge)). - Order("received_at ASC"). - First(&oldestRetryable).Error; err == nil && oldestRetryable.ReceivedAt.Before(since) { - log.Printf("[EmailSync] Rewinding window to %s to retry a previous failure", - oldestRetryable.ReceivedAt.Format(time.RFC3339)) - since = oldestRetryable.ReceivedAt - } - - // Fetch emails from Microsoft Graph - emails, err := s.fetchEmails(ctx, since) - if err != nil { - return fmt.Errorf("fetching emails: %w", err) - } - - log.Printf("[EmailSync] Fetched %d emails since %s", len(emails), since.Format(time.RFC3339)) - - // Filter by subject/sender patterns - filtered := s.filterEmails(emails) - log.Printf("[EmailSync] %d emails passed filters", len(filtered)) - - var created, updated, skipped, errored int - - for _, email := range filtered { - // Dedup check. A row is terminal — and so genuinely skippable — if it - // succeeded, or if it failed the maximum number of times. A row that - // failed but has attempts left is deliberately NOT skipped: it is - // reprocessed below and the same row updated, so a transient Claude - // or network outage no longer drops the email permanently. - var existing models.ProcessedEmail - found := s.DB.Where("graph_message_id = ?", email.ID).First(&existing).Error == nil - if found && !retryableFailure(&existing) { - skipped++ - continue - } - if found { - log.Printf("[EmailSync] Retrying previously failed email %q (attempt %d of %d)", - email.Subject, existing.Attempts+1, maxEmailAttempts) - } - - action, jobAppID, processErr := s.processEmail(ctx, email) - - // The row carries the outcome either way. On failure the attempt - // counter advances, so repeated failures walk the row towards the cap - // and it eventually stops being retried. A cancelled sync (the admin - // closed the tab mid-backlog, or nginx cut the request) is not a - // failure of the email, though: attempts must not advance for it, or - // two closed tabs would strand a healthy email at the cap and skip it - // forever. Writing nothing preserves the existing row untouched, so it - // is simply retried at the next sync. - if processErr != nil && errors.Is(processErr, context.Canceled) { - skipped++ - continue - } - - record := models.ProcessedEmail{ - GraphMessageID: email.ID, - Subject: truncate(email.Subject, 255), - Action: action, - JobAppID: jobAppID, - ReceivedAt: parseReceivedAt(email.ReceivedDateTime), - Attempts: existing.Attempts + 1, - } - - if processErr != nil { - log.Printf("[EmailSync] Error processing email %q: %v", email.Subject, processErr) - record.Action = "error" - record.JobAppID = nil - if record.Attempts >= maxEmailAttempts { - log.Printf("[EmailSync] Email %q has failed %d times; giving up on it", - email.Subject, record.Attempts) - } - s.saveProcessed(found, &existing, &record) - errored++ - continue - } - - s.saveProcessed(found, &existing, &record) - - switch action { - case "created": - created++ - case "updated": - updated++ - default: - skipped++ - } - } - - log.Printf("[EmailSync] Sync complete: %d fetched, %d filtered, %d created, %d updated, %d skipped, %d errors", - len(emails), len(filtered), created, updated, skipped, errored) - - return nil -} - -// fetchEmails retrieves emails since the given time using the configured -// backend, normalising both into []graphMessage. -func (s *EmailSyncService) fetchEmails(ctx context.Context, since time.Time) ([]graphMessage, error) { - if s.Config.Backend == "imap" { - return s.fetchEmailsIMAP(since) - } - return s.fetchEmailsGraph(ctx, since) -} - -// fetchEmailsGraph retrieves emails from the Microsoft Graph API since the given time. -func (s *EmailSyncService) fetchEmailsGraph(ctx context.Context, since time.Time) ([]graphMessage, error) { - var all []graphMessage - - sinceStr := since.UTC().Format("2006-01-02T15:04:05Z") - params := url.Values{ - "$filter": {fmt.Sprintf("receivedDateTime ge %s", sinceStr)}, - "$select": {"id,subject,from,receivedDateTime,body,bodyPreview"}, - "$top": {"50"}, - "$orderby": {"receivedDateTime asc"}, - } - - // Graph paginates with @odata.nextLink, which already carries every query - // parameter, so the loop below only builds this first URL by hand. - nextURL := fmt.Sprintf("https://graph.microsoft.com/v1.0/me/messages?%s", params.Encode()) - - for nextURL != "" { - req, err := http.NewRequestWithContext(ctx, "GET", nextURL, nil) - if err != nil { - return nil, err - } - - resp, err := s.HTTPClient.Do(req) - if err != nil { - return nil, err - } - - body, err := io.ReadAll(resp.Body) - resp.Body.Close() - - // Status is checked before the read error so that a non-200 reports - // Graph's own error body rather than a generic read failure. - if resp.StatusCode != http.StatusOK { - return nil, fmt.Errorf("Graph API returned %d: %s", resp.StatusCode, string(body)) - } - - if err != nil { - return nil, err - } - - var result graphMessagesResponse - if err := json.Unmarshal(body, &result); err != nil { - return nil, fmt.Errorf("parsing response: %w", err) - } - - all = append(all, result.Value...) - nextURL = result.NextLink - } - - return all, nil -} - -// filterEmails returns only emails that match subject keywords or sender domains. -func (s *EmailSyncService) filterEmails(emails []graphMessage) []graphMessage { - var matched []graphMessage - for _, email := range emails { - if s.matchesFilter(email) { - matched = append(matched, email) - } - } - return matched -} - -// matchesFilter reports whether an email looks job-related on subject or -// sender alone. See subjectKeywords for why this errs towards including too -// much. -func (s *EmailSyncService) matchesFilter(email graphMessage) bool { - subjectLower := strings.ToLower(email.Subject) - for _, kw := range subjectKeywords { - if strings.Contains(subjectLower, kw) { - return true - } - } - - senderAddr := strings.ToLower(email.From.EmailAddress.Address) - for _, domain := range senderDomains { - if strings.HasSuffix(senderAddr, "@"+domain) || strings.HasSuffix(senderAddr, "."+domain) { - return true - } - } - - return false -} - -// emailClassifyPath is the Python route, internal in the same way as the -// rowing and job-posting readers' (see python_call.go). -const emailClassifyPath = "/internal/email/classify" - -// maxClassifyRunes mirrors MAX_MESSAGE_CHARS in python/app/email_classify.py, -// which answers 422 to anything longer. cleanEmailBody already caps the body -// far below this, so the limit only bites on a pathological subject or sender -// — but a 422 would be recorded as a failed attempt and retried to the cap, -// so the cut is made here rather than left to chance. -const maxClassifyRunes = 200_000 - -// classifierMessage formats one email as the classifier's user turn: Subject, -// From and Date lines, a blank line, then the cleaned body. The Python side -// passes the string to Claude unchanged, so this layout is part of what the -// prompt there was written against. -// -// The result is cut to maxClassifyRunes on a rune boundary. The body comes -// last, so it is what gives way first. -func classifierMessage(email graphMessage) string { - msg := fmt.Sprintf("Subject: %s\nFrom: %s <%s>\nDate: %s\n\n%s", - email.Subject, - email.From.EmailAddress.Name, - email.From.EmailAddress.Address, - email.ReceivedDateTime, - cleanEmailBody(email.Body.Content, email.Body.ContentType), - ) - // Counting runes means converting; skip it for the ordinary case, where - // even the byte length (never less than the rune count) is under the cap. - if len(msg) <= maxClassifyRunes { - return msg - } - runes := []rune(msg) - if len(runes) <= maxClassifyRunes { - return msg - } - return string(runes[:maxClassifyRunes]) -} - -// classifyEmail asks the Python service what an email is. Every failure — -// the service unreachable, Claude failing (502), no API key (503), a reply -// that will not decode — comes back as an error, which SyncEmails records as -// a retryable failure of this email. -func (s *EmailSyncService) classifyEmail(ctx context.Context, email graphMessage) (EmailAnalysis, error) { - analysis, err := CallPython[EmailAnalysis](ctx, s.PythonURL, emailClassifyPath, struct { - Message string `json:"message"` - }{classifierMessage(email)}) - if err != nil { - // %w keeps context.Canceled visible to SyncEmails, which must not - // count an abandoned sync against the email. - return EmailAnalysis{}, fmt.Errorf("classifying email: %w", err) - } - return analysis, nil -} - -// processEmail has a single email classified and creates/updates a JobApplication. -// Returns the action taken ("created", "updated", "skipped") and the job application ID if applicable. -func (s *EmailSyncService) processEmail(ctx context.Context, email graphMessage) (string, *uint, error) { - analysis, err := s.classifyEmail(ctx, email) - if err != nil { - return "", nil, err - } - - if !analysis.IsJobEmail { - return "skipped", nil, nil - } - - if analysis.Company == "" || analysis.JobTitle == "" { - return "skipped", nil, nil - } - - // Applications are identified by (company, job title) compared - // case-insensitively — there is no external id to match on. Claude - // wording the same role slightly differently therefore creates a second - // application rather than updating the first. The most recent match wins - // when there are several. - // The lookup is Unscoped: a deleted-with-notes row is stored, not purged - // (see models.JobApplication), so invisibility here makes the matcher - // believe the application never existed and a follow-up email in the same - // thread re-creates it — the admin deletes it, it comes back. A hit on a - // deleted row instead becomes a suppression: nothing is updated, nothing - // is created, and the pipeline leaves the deletion to stand. - var existing models.JobApplication - found := s.DB.Unscoped().Where("LOWER(company) = LOWER(?) AND LOWER(job_title) = LOWER(?)", - analysis.Company, analysis.JobTitle). - Order("created_at DESC"). - First(&existing).Error == nil - - if found && existing.DeletedAt.Valid { - return "skipped", nil, nil - } - - if found && analysis.Action == "update" { - return s.updateJobApplication(&existing, &analysis) - } - - if !found { - return s.createJobApplication(&analysis) - } - - // Found but action is "create" — the record already exists, skip - return "skipped", &existing.ID, nil -} - -// NormalizeStatus coerces Claude's status guess into the tracked vocabulary, -// lowering the case it occasionally drifts on and rejecting anything outside -// statusOrder. An unrecognised status stored verbatim would disable the -// forward-only guard for that row (updateJobApplication allows any recognised -// status over an unknown one), so the safe fallback is the pipeline's default. -// -// It is for values that arrive outside GraphQL: the classifier's answer and -// the capture endpoint's body. 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" -} - -// createJobApplication inserts a new application from Claude's analysis. -func (s *EmailSyncService) createJobApplication(analysis *EmailAnalysis) (string, *uint, error) { - app := models.JobApplication{ - Company: analysis.Company, - JobTitle: analysis.JobTitle, - Status: NormalizeStatus(analysis.Status), - Location: analysis.Location, - URL: analysis.URL, - Notes: analysis.Notes, - } - - // The prompt asks for YYYY-MM-DD but full RFC3339 comes back often enough - // to be worth trying first; an unparseable date is dropped silently. - if analysis.AppliedAt != nil { - if t, err := time.Parse(time.RFC3339, *analysis.AppliedAt); err == nil { - app.AppliedAt = &t - } else if t, err := time.Parse("2006-01-02", *analysis.AppliedAt); err == nil { - app.AppliedAt = &t - } - } - - if app.Status == "" { - app.Status = "applied" - } - - if err := s.DB.Create(&app).Error; err != nil { - return "", nil, fmt.Errorf("creating job application: %w", err) - } - - log.Printf("[EmailSync] Created job application: %s at %s (status: %s)", app.JobTitle, app.Company, app.Status) - return "created", &app.ID, nil -} - -// StatusAdvances reports whether next is a forward move from current through -// statusOrder. Emails commonly arrive out of order (a delayed "thanks for -// applying" after an interview invite), and this is what stops a stale email -// dragging an 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. -// -// Exported because the browser capture endpoint applies the same rule. -func StatusAdvances(current, next string) bool { - nextOrder, nextExists := statusOrder[next] - currentOrder, currentExists := statusOrder[current] - return nextExists && (!currentExists || nextOrder > currentOrder) -} - -// updateJobApplication advances an existing application's status, but only -// ever forwards (see StatusAdvances). -func (s *EmailSyncService) updateJobApplication(existing *models.JobApplication, analysis *EmailAnalysis) (string, *uint, error) { - if !StatusAdvances(existing.Status, analysis.Status) { - return "skipped", &existing.ID, nil - } - - existing.Status = analysis.Status - - // A row captured as "saved" has no applied date; the email that moves it - // to "applied" is the best evidence of when that happened. - if existing.AppliedAt == nil && existing.Status == "applied" { - now := time.Now() - existing.AppliedAt = &now - } - - // Append to notes if Claude provided any - if analysis.Notes != nil && *analysis.Notes != "" { - if existing.Notes != nil && *existing.Notes != "" { - combined := *existing.Notes + "\n" + *analysis.Notes - existing.Notes = &combined - } else { - existing.Notes = analysis.Notes - } - } - - if err := s.DB.Save(existing).Error; err != nil { - return "", nil, fmt.Errorf("updating job application: %w", err) - } - - log.Printf("[EmailSync] Updated job application: %s at %s (status: %s)", existing.JobTitle, existing.Company, existing.Status) - return "updated", &existing.ID, nil -} - -// cleanEmailBody reduces an email body to plain-ish text before it is sent to -// the classifier, cutting token cost and noise. -// -// The HTML handling is a regex tag-strip, not a parser: fine for extracting -// prose, but it would mangle inline - - - - diff --git a/vue/src/views/CV/JobSources.vue b/vue/src/views/CV/JobSources.vue deleted file mode 100644 index 9bd39a8..0000000 --- a/vue/src/views/CV/JobSources.vue +++ /dev/null @@ -1,198 +0,0 @@ - - - - - diff --git a/vue/src/views/CV/jobStatus.js b/vue/src/views/CV/jobStatus.js deleted file mode 100644 index bd380b2..0000000 --- a/vue/src/views/CV/jobStatus.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * The job-application status vocabulary, as the tracker at /cv/jobs shows it. - * - * This is a COPY. The source of truth is server-side: `enum JobStatus` in - * backend/graph/schema/job_application.graphql, ranked by `statusOrder` in - * backend/services/email_sync.go (the email pipeline only ever moves a row - * forward through that order). The server rejects any value outside the enum, - * so a status added here alone cannot be saved — add it there first. - * - * There is a third copy in vue/public/job-capture.user.js (STATUS_LABELS). A - * userscript is a single file installed into the browser and cannot import - * modules, so it has to be kept in step by hand. - * - * Values are the lowercase keys that go over the wire; labels are display-only. - */ - -export const STATUS_OPTIONS = [ - // Captured from the browser but not applied to yet. No email produces it. - { value: "saved", label: "Saved" }, - { value: "applied", label: "Applied" }, - { value: "screening", label: "Screening" }, - { value: "assessment", label: "Assessment" }, - { value: "interviewing", label: "Interviewing" }, - { value: "offer", label: "Offer" }, - { value: "rejected", label: "Rejected" }, - { value: "withdrawn", label: "Withdrawn" }, -]; - -// Statuses still in play — used to decide whether a row is worth chasing. -// "saved" is absent on purpose: nobody owes a reply on a job not applied to. -export const OPEN_STATUSES = ["applied", "screening", "assessment", "interviewing"]; diff --git a/vue/src/views/CV/jobs-shared.css b/vue/src/views/CV/jobs-shared.css deleted file mode 100644 index c0a8031..0000000 --- a/vue/src/views/CV/jobs-shared.css +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Form controls shared by the job tracker's components (JobApplications.vue and - * the JobReferences / JobApplicationForm components it renders). - * - * These lived in JobApplications.vue's scoped block until the page was split. - * Scoped styles stop at a child component's root element, so the inputs inside - * the children would have lost them; this file is imported by each component - * instead. It is unscoped, so every selector is prefixed with the page's - * `.ja-root` class — which also keeps the specificity at (0,2,0), the same as - * the scoped originals, so they still beat CVLayout's `.cv-layout input`. - * - * Colours are the paper palette from CVLayout.vue. - */ - -.ja-root .ja-input { - padding: 0.35rem 0.6rem; - border: 1px solid var(--color-line); - border-radius: 4px; - font-size: 0.85rem; - background: var(--color-paper); - flex: 1; - min-width: 120px; -} - -.ja-root .ja-input:focus { - outline: none; - border-color: var(--color-ink-muted); -} - -.ja-root .ja-select { - cursor: pointer; -} - -.ja-root .ja-input-sm { - padding: 0.2rem 0.4rem; - font-size: 0.8rem; - width: 100%; - min-width: 0; -} diff --git a/vue/src/views/admin/CaptureToken.vue b/vue/src/views/admin/CaptureToken.vue deleted file mode 100644 index 864014f..0000000 --- a/vue/src/views/admin/CaptureToken.vue +++ /dev/null @@ -1,127 +0,0 @@ - - - - - diff --git a/vue/src/views/admin/Diagnostics.vue b/vue/src/views/admin/Diagnostics.vue index d0e4fa1..f0de8ee 100644 --- a/vue/src/views/admin/Diagnostics.vue +++ b/vue/src/views/admin/Diagnostics.vue @@ -3,8 +3,8 @@ * Admin panel: tail of the backend log. * * GET /api/admin/logs returns JSON read from the filesystem, not GraphQL — - * it is not part of the site's data model. Configuration and the job capture - * token, which used to share this tab, are on the Environment tab. + * it is not part of the site's data model. Configuration, which used to share + * this tab, is on the Environment tab. * * An admin who remounts the component via tab switches re-triggers * onMounted, which is the desired "refresh on tab change" behaviour. diff --git a/vue/src/views/admin/Environment.vue b/vue/src/views/admin/Environment.vue index 701920e..feeebfe 100644 --- a/vue/src/views/admin/Environment.vue +++ b/vue/src/views/admin/Environment.vue @@ -19,7 +19,6 @@ import { ref, reactive, computed, onMounted, onUnmounted } from "vue"; import { api } from "@/api"; import Button from "@/components/input/Button.vue"; import SecretReveal from "@/components/admin/SecretReveal.vue"; -import CaptureToken from "./CaptureToken.vue"; import "./env.css"; const groups = ref([]); @@ -367,8 +366,6 @@ onUnmounted(stopPolling); - -