With an agent named, the rail's tag, company and place counts, Remote included, cover the roles that agent's feed shows, past its fetch gate; and the affinity note names the order What I'm looking for.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
0b92f19f4d
commit
8c3c51dd9f
4 files changed
+106
-35
No files matched your search
+17
-9
@@ -294,10 +294,12 @@ class FiltersOut(BaseModel):
|
||||
def list_filters(store: StoreDep, agent: int | None = None) -> FiltersOut:
|
||||
"""The tag vocabulary for the feed's filter row, most-used first. The
|
||||
companies `agent` hid (the default agent's without one) are left out,
|
||||
matching `/api/roles`."""
|
||||
matching `/api/roles`; with `agent` named, so is every role its fetch
|
||||
gate rejects, so a count is what the feed lists for the tag."""
|
||||
hidden_for = _agent_id(store, agent)
|
||||
return FiltersOut(tags=[TagCount(tag=tag, count=count, unread=unread)
|
||||
for tag, count, unread in store.tag_counts(hidden_for)])
|
||||
for tag, count, unread in store.tag_counts(
|
||||
hidden_for, fetch_gate=agent is not None)])
|
||||
|
||||
|
||||
# ------------------------------------------------------------ suggestions
|
||||
@@ -343,14 +345,17 @@ def suggest_companies(
|
||||
folded as places are (`places.fold`), so `orsted` finds Ørsted and
|
||||
`kobenhavn` finds a name with København in it. By open roles, most
|
||||
first. The companies `agent` (the default agent when absent) hid are
|
||||
left out, as the feed leaves them out. An empty `q` suggests nothing."""
|
||||
left out, as the feed leaves them out; with `agent` named, the count is
|
||||
the roles its feed shows, past its fetch gate. An empty `q` suggests
|
||||
nothing."""
|
||||
text = places.fold(q)
|
||||
if not text:
|
||||
return []
|
||||
aliases = store.company_aliases()
|
||||
companies = store.open_companies(_agent_id(store, agent), fetch_gate=agent is not None)
|
||||
found = [CompanySuggestion(key=key, name=names[0] if names else key, count=count,
|
||||
affinity=affinity)
|
||||
for key, names, count, affinity in store.open_companies(_agent_id(store, agent))
|
||||
for key, names, count, affinity in companies
|
||||
if any(_starts_a_word(text, places.fold(name)) for name in names)
|
||||
or any(_starts_a_word(text, fold) for fold in aliases.get(key, ()))]
|
||||
found.sort(key=lambda c: (-c.count, c.name.casefold()))
|
||||
@@ -370,11 +375,13 @@ def suggest_places(
|
||||
open role's place line and every open remote role's area). The count of
|
||||
`remote:any` is the remote roles in the scope of `agent`, the default
|
||||
agent when absent, as the feed counts them, and the other remote tokens
|
||||
are kept to that agent's scope, its `require` gates on country. An empty
|
||||
`q` suggests nothing."""
|
||||
are kept to that agent's scope, its `require` gates on country. With
|
||||
`agent` named, every count is of the roles its feed shows, past its
|
||||
fetch gate. An empty `q` suggests nothing."""
|
||||
if not places.fold(q):
|
||||
return []
|
||||
viewer = _agent_id(store, agent)
|
||||
shown = viewer if agent is not None else None
|
||||
gaz = store.gazetteer()
|
||||
found = store.agent(viewer) if viewer is not None else None
|
||||
scope = {p for g in (found.gates if found is not None else ())
|
||||
@@ -382,10 +389,11 @@ def suggest_places(
|
||||
for v in g.values for p in gaz.lookup(f"country:{v}") or ()}
|
||||
return [PlaceSuggestion(token=s.token, label=s.label, kind=s.kind, count=s.count)
|
||||
for s in places.suggest(
|
||||
q, store.open_places(), limit, remote=store.open_remote_areas(),
|
||||
q, store.open_places(shown), limit, remote=store.open_remote_areas(shown),
|
||||
gaz=gaz, scope=scope,
|
||||
remote_any=lambda: store.count_roles(places=["remote:any"], agent=viewer,
|
||||
by_score=False))]
|
||||
by_score=False,
|
||||
fetch_gate=agent is not None))]
|
||||
|
||||
|
||||
@router.get("/places/labels")
|
||||
@@ -772,7 +780,7 @@ def set_affinity(key: str, body: AffinityBody, store: StoreDep,
|
||||
"""-1 hidden, 0 neutral, 1 liked, 2 favourite, for `body.agent` or the
|
||||
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 Agent match until `score` has run, so it queues one
|
||||
seen in "What I'm looking for" 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")
|
||||
|
||||
Reference in new issue
Block a user