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