A replaced or detached board takes its failure record with it

The pull records a board that fails on every fetch under ats:failing:<target>, and set_board can now move a company to another board. The old target's record would have outlived the board and counted in `app companies check` for good.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Fable 5.1 committed 2026-09-29 14:17:20 +02:00
1 parent 43773efc53
commit 04da463e9f
2 files changed
+28 -1

No files matched your search

+12 -1
View File
@@ -19,7 +19,7 @@ from typing import TYPE_CHECKING, Any
from app.config import Config
from app.models import Subscription, company_key
from app.storage import Store
from app.jobs.pull import search_target
from app.jobs.pull import FAILING, search_target
if TYPE_CHECKING:
from app.jobs.discover import Discovery
@@ -82,9 +82,12 @@ def set_board(store: Store, key: str, board: str, *, name: str = "",
else:
writes.setdefault("careers_url", careers_url(board))
writes.update(ats=host, ats_slug=slug)
before = store.company_subscription(key)
_company, sub, closed = store.set_company_board(key, board, host=host, name=name,
fields=writes)
assert sub is not None
if before is not None and before.target != board:
_forget_failing(store, before.target)
return sub, None if rows is None else len(rows), closed
@@ -99,9 +102,17 @@ def detach_board(store: Store, key: str) -> int:
if sub is None or not sub.show:
raise ValueError(f"{key} has no board to detach")
_company, _sub, closed = store.set_company_board(key, "")
_forget_failing(store, sub.target)
return closed
def _forget_failing(store: Store, target: str) -> None:
"""Drop what the pull recorded about a board nobody reads any more: a
record of `target` failing would otherwise outlive the board, and count
in `app companies check` for good."""
store.state.pop(FAILING + target, None)
def add_board(store: Store, board: str, name: str) -> tuple[Subscription, int]:
"""Follow one company by its ATS board: `set_board` keyed by `name`, so
a company that exists gets the board attached or replaced. Returns the
+16
View File
@@ -287,3 +287,19 @@ def test_cli_seed_prints_counts_and_problems(
captured = capsys.readouterr()
assert json.loads(captured.out) == {"added": 1, "boards": 0, "skipped": 0, "total": 1}
assert "companies seed: odd: 'nosuch:odd' is not a known board" in captured.err
def test_replacing_or_detaching_a_board_forgets_that_it_was_failing(
store: Store, boards: Boards) -> None:
from app.jobs.pull import FAILING, failing_boards
sources.set_board(store, "acme", "greenhouse:acme", name="Acme")
store.state[FAILING + "greenhouse:acme"] = '{"since": "2026-09-01T00:00:00+00:00", "reason": "404 Not Found"}'
assert "greenhouse:acme" in failing_boards(store)
sources.set_board(store, "acme", "ashby:acme")
assert failing_boards(store) == {}
store.state[FAILING + "ashby:acme"] = '{"since": "2026-09-01T00:00:00+00:00", "reason": "timeout"}'
sources.detach_board(store, "acme")
assert failing_boards(store) == {}