Treat remote_from as remote reach and suggest the remote tokens with counts

/api/suggest/places offers "Remote" (remote:any) first for "remote", counted in the scope of the agent asked for or the default agent, then the countries, then "Remote · <place>".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-09-30 16:00:06 +02:00
1 parent 6f2b1ff72a
commit d0be7c1162
2 files changed
+26 -10

No files matched your search

+17 -5
View File
@@ -287,7 +287,7 @@ class PlaceSuggestion(BaseModel):
token: str
label: str
kind: Literal["country", "region", "place"]
kind: Literal["country", "region", "place", "remote"]
count: int
@@ -331,13 +331,25 @@ def suggest_companies(
def suggest_places(
store: StoreDep,
q: str = "",
agent: int | None = None,
limit: Annotated[int, Query(ge=1, le=50)] = 12,
) -> list[PlaceSuggestion]:
"""Place tokens for the text typed so far: countries, then regions, then
towns, each by open roles (`places.suggest`, over every open role's place
line). An empty `q` suggests nothing."""
"""Place tokens for the text typed so far: "Remote" (`remote:any`) when
`q` starts "remote", countries, the remote tokens ("Remote · Denmark"),
regions, then towns, each by open roles (`places.suggest`, over every
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. An empty `q` suggests
nothing."""
if not places.fold(q):
return []
viewer = _agent_id(store, agent)
return [PlaceSuggestion(token=s.token, label=s.label, kind=s.kind, count=s.count)
for s in places.suggest(q, store.open_places(), limit)]
for s in places.suggest(
q, store.open_places(), limit, remote=store.open_remote_areas(),
gaz=store.gazetteer(),
remote_any=lambda: store.count_roles(places=["remote:any"], agent=viewer,
by_score=False))]
@router.get("/places/labels")