Judge an employer known only from a search; the Companies list says "from job boards"
Store.set_affinity creates a minimal company row (key, and the name its roles give most often) for a key with roles and no row, so a Jobindex or Adzuna employer can be hidden or liked; the reader draws the control for any role with a company_key and reloads the company list after the first change. /api/companies derives from_search: no ats subscription (detached included) and no ats, careers_url or domain. companies.js labels it "from job boards" and keeps it out of "Not readable yet". Co-Authored-By: Claude Opus <noreply@anthropic.com>
This commit is contained in:
1 parent
91d15fcc7d
commit
b2c8c08f7f
6 files changed
+78
-15
No files matched your search
+13
-4
@@ -268,7 +268,10 @@ class CompanyOut(BaseModel):
|
||||
no `board` and an `ats` is one the app cannot read yet; `careers_url` is
|
||||
where a person can. `failing_since` and `failing_reason` say since when
|
||||
the board has failed on every fetch and why it last did, both empty
|
||||
while it answers."""
|
||||
while it answers. `from_search` marks a row that exists only because a
|
||||
search listed its roles and somebody judged it (`Store.set_affinity`):
|
||||
no board, not even a detached one, and no `ats`, `careers_url` or
|
||||
`domain`, which every way of following a company writes one of."""
|
||||
|
||||
key: str
|
||||
name: str
|
||||
@@ -283,6 +286,7 @@ class CompanyOut(BaseModel):
|
||||
country: str = ""
|
||||
failing_since: str = ""
|
||||
failing_reason: str = ""
|
||||
from_search: bool = False
|
||||
|
||||
|
||||
def _company_boards(store: Store) -> dict[str, tuple[int, str, bool, str]]:
|
||||
@@ -305,6 +309,7 @@ def list_companies(store: StoreDep, agent: int | None = None) -> list[CompanyOut
|
||||
"""Every company, with `affinity` as `agent` (the default agent when
|
||||
absent) has it; 0 throughout when there is no agent."""
|
||||
boards = _company_boards(store)
|
||||
ever_boarded = {company_key(s.company) for s in store.subscriptions(source="ats")}
|
||||
counts = store.open_role_counts()
|
||||
failing = jobs.pull.failing_boards(store)
|
||||
out = []
|
||||
@@ -316,7 +321,9 @@ def list_companies(store: StoreDep, agent: int | None = None) -> list[CompanyOut
|
||||
open_roles=counts.get(c.key, 0), ats=c.ats,
|
||||
ats_slug=c.ats_slug, careers_url=c.careers_url,
|
||||
country=c.country,
|
||||
failing_since=since, failing_reason=reason))
|
||||
failing_since=since, failing_reason=reason,
|
||||
from_search=not (c.key in ever_boarded or c.ats
|
||||
or c.careers_url or c.domain)))
|
||||
return out
|
||||
|
||||
|
||||
@@ -410,8 +417,10 @@ class AffinityOut(Company):
|
||||
def set_affinity(key: str, body: AffinityBody, store: StoreDep,
|
||||
queue: QueueDep) -> AffinityOut:
|
||||
"""-1 hidden, 0 neutral, 1 liked, 2 favourite, for `body.agent` or the
|
||||
default agent. A change here is not seen in Best match until `score` has
|
||||
run, so it queues one (`_score_after_change`) and answers with its id."""
|
||||
default agent. A key with roles and no company row gets one first (see
|
||||
`Store.set_affinity`); 404 for a key with neither. A change here is not
|
||||
seen in Best match until `score` has run, so it queues one
|
||||
(`_score_after_change`) and answers with its id."""
|
||||
if body.affinity not in AFFINITY:
|
||||
raise HTTPException(422, "affinity is -1, 0, 1 or 2")
|
||||
owner = _agent_or_default(store, body.agent)
|
||||
|
||||
Reference in new issue
Block a user