From 0458c9c17227202991e883a1cf3b6e3d400a4954 Mon Sep 17 00:00:00 2001 From: Wolf Date: Tue, 29 Sep 2026 16:23:19 +0200 Subject: [PATCH] Take a Platsbanken region in the API and the CLI, and trust its and Teamtailor's posted date Co-Authored-By: Claude Fable 5.1 --- app/cli.py | 6 ++++-- app/models.py | 6 +++++- app/web/api.py | 3 ++- tests/test_web.py | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/cli.py b/app/cli.py index 2b33b21..6017af6 100644 --- a/app/cli.py +++ b/app/cli.py @@ -95,7 +95,7 @@ def build_parser() -> argparse.ArgumentParser: searches_sub = searches.add_subparsers(dest="action", required=True) search_add = searches_sub.add_parser( "add", help="run a search once, then save it for every pull (or update it)") - search_add.add_argument("provider", choices=["jobindex", "adzuna"]) + search_add.add_argument("provider", choices=["jobindex", "adzuna", "platsbanken"]) search_add.add_argument("name", help='what to call it, e.g. "Copenhagen backend"') search_add.add_argument("--q", required=True, help="the query, in the provider's own syntax") @@ -104,6 +104,8 @@ def build_parser() -> argparse.ArgumentParser: search_add.add_argument("--country", default="", help="adzuna country: gb, de, nl, fr, at, be, es, it, pl, ch") search_add.add_argument("--where", default="", help="adzuna place, e.g. Berlin") + search_add.add_argument("--region", default="", + help="platsbanken län id: CaRE_1nn_cSU is Skåne, empty all of Sweden") search_add.add_argument("--pages", type=int, default=0, help="result pages per pull (default 5, at most 10)") searches_sub.add_parser("list", help="every saved search and its open roles") @@ -423,7 +425,7 @@ def add_search(config: config_mod.Config, store: Store, args: argparse.Namespace try: params = jobs.sources.search_params(args.provider, args.q, area=args.area, country=args.country, where=args.where, - pages=args.pages) + region=args.region, pages=args.pages) sub, found, complete = jobs.sources.save_search(config, store, args.provider, args.name, params) except ValueError as exc: diff --git a/app/models.py b/app/models.py index 04219c2..562ac85 100644 --- a/app/models.py +++ b/app/models.py @@ -681,12 +681,16 @@ AFFINITY = range(-1, 3) #: deployment carries no Adzuna key (`plugins.search`'s own docstring: #: "not yet run live") and no Adzuna subscription exists to fetch. #: +#: - `teamtailor`: the feed's `pubDate`, and `platsbanken`: `publication_date`, +#: both named as publication. Read on live feeds on 2026-09-29, where the +#: dates were spread over weeks, not checked against stored roles. +#: #: A host not listed here, or a role whose stored `published_at` fails the #: sanity check in `posted_at`, keeps `first_seen` as its posted date — the #: safe default this migration is replacing everywhere else. TRUSTED_POSTED_HOSTS: frozenset[str] = frozenset({ "greenhouse", "lever", "ashby", "workable", "smartrecruiters", "recruitee", - "personio", "jobindex", "adzuna", + "personio", "teamtailor", "jobindex", "adzuna", "platsbanken", }) #: A `published_at` before this is a parsing slip or a placeholder, not a diff --git a/app/web/api.py b/app/web/api.py index 23ea8fe..229f8b6 100644 --- a/app/web/api.py +++ b/app/web/api.py @@ -538,6 +538,7 @@ class SearchBody(BaseModel): area: int = 0 country: str = "" where: str = "" + region: str = "" pages: Annotated[int, Field(ge=0, le=10)] = 0 @@ -545,7 +546,7 @@ def _params(body: SearchBody) -> dict[str, Any]: try: return jobs.sources.search_params(body.provider, body.q, area=body.area, country=body.country, where=body.where, - pages=body.pages) + region=body.region, pages=body.pages) except ValueError as exc: raise HTTPException(422, str(exc)) from exc diff --git a/tests/test_web.py b/tests/test_web.py index a10dc2f..975b72a 100644 --- a/tests/test_web.py +++ b/tests/test_web.py @@ -732,7 +732,7 @@ def test_the_agents_page_lists_and_edits_search_agents(client: TestClient) -> No template = page[page.index('")] assert 'id="agent-form"' in template and 'id="a-cancel"' in template assert 'id="a-name"' in page and 'placeholder="My search"' in page - assert 'id="a-intent"' in page and "