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:
1 parent
0ad47605fd
commit
a63eed2e56
10 files changed
+66
-36
No files matched your search
+19
-9
@@ -328,7 +328,7 @@ def site_facets(store: Store, subs: Iterable[Subscription]) -> dict[str, dict[st
|
||||
out: dict[str, dict[str, dict[str, str]]] = {}
|
||||
for sub in subs:
|
||||
module = readers.HOSTS.get(sub.target.partition(":")[0])
|
||||
if module is None or not _runner.declared(module) \
|
||||
if module is None \
|
||||
or "ids" not in (module.READS.filters.country, module.READS.filters.remote):
|
||||
continue
|
||||
try:
|
||||
@@ -399,8 +399,9 @@ def _site(module: Any, ask: readers.Ask, facets: Mapping[str, Mapping[str, str]]
|
||||
before any are kept), as `_runner.series` drops them: what is asked,
|
||||
then what the site does not know ("DK · SE not on this site · no remote
|
||||
option"), after `lead` and before `roles`; or, with nothing left to
|
||||
ask, "site lists none of DK, SE: nothing asked". "" when the site knows
|
||||
every value, or `lead` is "" and something is still asked."""
|
||||
ask, "site lists none of DK, SE: nothing asked, not closing", since the
|
||||
runner reads such a board as incomplete. "" when the site knows every
|
||||
value, or `lead` is "" and something is still asked."""
|
||||
if facets is None:
|
||||
return ""
|
||||
reads = module.READS.filters
|
||||
@@ -418,9 +419,9 @@ def _site(module: Any, ask: readers.Ask, facets: Mapping[str, Mapping[str, str]]
|
||||
remote = bool(ask.remote) and not no_remote
|
||||
if not (known or ask.places or remote):
|
||||
if not missing:
|
||||
return "site has no remote option: nothing asked"
|
||||
return "site has no remote option: nothing asked, not closing"
|
||||
named = _codes(missing) + (["remote"] if no_remote else [])
|
||||
return f"site lists none of {', '.join(named)}: nothing asked"
|
||||
return f"site lists none of {', '.join(named)}: nothing asked, not closing"
|
||||
if not lead:
|
||||
return ""
|
||||
words = [", ".join(_codes(known) + list(ask.places) + (["remote"] if remote else []))]
|
||||
@@ -452,7 +453,9 @@ def line(found: Plan, sub: Subscription) -> str:
|
||||
a host that filters by its own ids, the line names what the site does
|
||||
not know once the runner has asked it (`_site`): "follows agents: DK ·
|
||||
SE not on this site · no remote option · all roles", or "site lists
|
||||
none of DK, SE: nothing asked"."""
|
||||
none of DK, SE: nothing asked, not closing", or, on a host with no remote
|
||||
filter while the agents want remote, "follows agents: DK, SE · remote not
|
||||
asked on SmartRecruiters · all roles"."""
|
||||
module = readers.HOSTS.get(sub.target.partition(":")[0])
|
||||
if module is None:
|
||||
return ""
|
||||
@@ -465,12 +468,19 @@ def line(found: Plan, sub: Subscription) -> str:
|
||||
lead = {"agents": "follows agents", "override": "set here"}.get(why, "")
|
||||
if site := _site(module, ask, found.facets.get(sub.target), lead, roles):
|
||||
return site
|
||||
# The reach wants remote roles and the host cannot be asked for them:
|
||||
# the read leaves them out, and the settle keeps the ones it has
|
||||
# (`app.jobs.pull`), so the line says so rather than "DK, SE".
|
||||
unasked = (f" · remote not asked on {module.LABEL}"
|
||||
if module.READS.filters.remote == "none"
|
||||
and _runner.remote_wanted(module, sub.params, found.for_subscription(sub))
|
||||
else "")
|
||||
if why == "countries":
|
||||
named = found.wide_names or f"{len(found.wide.countries)} countries"
|
||||
return f"all countries ({named}) · {roles}"
|
||||
return f"all countries ({named}){unasked} · {roles}"
|
||||
if why == "override":
|
||||
return f"set here: {_places(ask)} · {roles}"
|
||||
return f"follows agents: {_places(ask)} · {roles}"
|
||||
return f"set here: {_places(ask)}{unasked} · {roles}"
|
||||
return f"follows agents: {_places(ask)}{unasked} · {roles}"
|
||||
if ask.terms:
|
||||
if given.everywhere:
|
||||
return f"all countries (everywhere) · {roles}"
|
||||
|
||||
+4
-1
@@ -20,7 +20,7 @@ from urllib.parse import urlsplit
|
||||
from app.config import Config
|
||||
from app.models import HAND_REASONS, Company, Subscription, company_key
|
||||
from app.storage import Store
|
||||
from app.jobs.pull import FAILING, search_target
|
||||
from app.jobs.pull import FAILING, SEARCH_FAILING, search_target
|
||||
from plugins import readers
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -436,6 +436,9 @@ def remove_search(store: Store, sub_id: int) -> tuple[Subscription, int]:
|
||||
if sub is None or sub.source != "search":
|
||||
raise KeyError(sub_id)
|
||||
store.unsubscribe(sub_id)
|
||||
# A record of the search failing would otherwise outlive it, as a
|
||||
# board's would (`_forget_failing`).
|
||||
store.state.pop(SEARCH_FAILING + sub.target, None)
|
||||
closed = store.close_subscription(sub_id)
|
||||
if closed:
|
||||
store.rebuild_dupes()
|
||||
|
||||
@@ -122,6 +122,15 @@
|
||||
const parts = [q, `${source.open_roles} open`];
|
||||
if (source.countries.length) parts.push(countries(source));
|
||||
sub.append(parts.join(" · "), " ");
|
||||
if (source.failing_since) {
|
||||
// The search has failed on every pull since then; after 21 days its
|
||||
// roles close, as a board's do (app/jobs/pull.py).
|
||||
const failing = document.createElement("span");
|
||||
failing.className = "failing";
|
||||
failing.textContent = `not answering since ${source.failing_since.slice(0, 10)}`
|
||||
+ (source.failing_reason ? `: ${source.failing_reason}` : "");
|
||||
sub.append("· ", failing, " ");
|
||||
}
|
||||
const edit = document.createElement("button");
|
||||
edit.type = "button";
|
||||
edit.className = "linky";
|
||||
|
||||
+15
-6
@@ -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"))
|
||||
|
||||
Reference in new issue
Block a user