Say remote not asked on the Companies line, show a failing search on its row, forget a removed search's record, and mark a read that asked nothing as not closing

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Fable 5.1 committed 2026-09-30 16:11:27 +02:00
1 parent 0ad47605fd
commit a63eed2e56
10 files changed
+66 -36

No files matched your search

+15 -6
View File
@@ -811,7 +811,9 @@ def mark_careers_opened(key: str, store: StoreDep) -> Company:
class SourceOut(BaseModel):
"""A board or a saved search, with what it brings in: its open roles, and
the countries they are in, most first."""
the countries they are in, most first. `failing_since` and
`failing_reason` say since when it has failed on every fetch and why it
last did (`jobs.pull.failing_boards`), both empty while it answers."""
id: int
source: str
@@ -822,6 +824,8 @@ class SourceOut(BaseModel):
on: bool
open_roles: int
countries: list[tuple[str, int]]
failing_since: str = ""
failing_reason: str = ""
class SourcesOut(BaseModel):
@@ -831,19 +835,23 @@ class SourcesOut(BaseModel):
adzuna_key: bool
def _source_out(sub: Subscription, countries: dict[str, int]) -> SourceOut:
def _source_out(sub: Subscription, countries: dict[str, int],
failing: dict[str, tuple[str, str]]) -> SourceOut:
since, reason = failing.get(sub.target, ("", ""))
return SourceOut(
id=sub.id, source=sub.source, target=sub.target, label=sub.label,
provider=sub.board, params=sub.params, on=bool(sub.subscribed and sub.fetch),
open_roles=sum(countries.values()),
countries=sorted(countries.items(), key=lambda kv: -kv[1]))
countries=sorted(countries.items(), key=lambda kv: -kv[1]),
failing_since=since, failing_reason=reason)
def _one_source(store: Store, sub_id: int) -> SourceOut:
sub = store.subscription(sub_id)
if sub is None:
raise HTTPException(404, f"no such board or search: {sub_id}")
return _source_out(sub, store.open_countries_by_subscription().get(sub_id, {}))
return _source_out(sub, store.open_countries_by_subscription().get(sub_id, {}),
jobs.pull.failing_boards(store))
@router.get("/sources")
@@ -851,9 +859,10 @@ def list_sources(store: StoreDep, config: ConfigDep) -> SourcesOut:
"""Every board not detached, and every search not removed. A board
switched off stays listed, so it can be switched back on."""
counts = store.open_countries_by_subscription()
searches = [_source_out(s, counts.get(s.id, {}))
failing = jobs.pull.failing_boards(store)
searches = [_source_out(s, counts.get(s.id, {}), failing)
for s in store.subscriptions(source="search") if s.show]
boards = [_source_out(s, counts.get(s.id, {}))
boards = [_source_out(s, counts.get(s.id, {}), failing)
for s in store.subscriptions(source="ats") if s.show]
return SourcesOut(searches=searches, boards=boards,
adzuna_key=jobs.sources.has_key(config, "adzuna"))