Merge main: read state and tags meet per-agent votes and affinity
The per-agent migration becomes v6 behind main's v5. A vote still stamps the role's read_at, tag counts hide the agent's hidden companies, and /api/filters takes the agent like /api/roles. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
commit
c69fb0b6c4
23 files changed
+2270
-717
No files matched your search
+52
-2
@@ -92,6 +92,24 @@ def unvote_role(uid: str, store: StoreDep, agent: int | None = None) -> Role:
|
||||
raise HTTPException(404, f"no such role: {uid}") from None
|
||||
|
||||
|
||||
@router.post("/roles/{uid}/read")
|
||||
def read_role(uid: str, store: StoreDep) -> Role:
|
||||
"""Mark a role read. Never hides it; a vote does this too, see `vote_role`."""
|
||||
try:
|
||||
return store.set_read(uid, True)
|
||||
except KeyError:
|
||||
raise HTTPException(404, f"no such role: {uid}") from None
|
||||
|
||||
|
||||
@router.delete("/roles/{uid}/read")
|
||||
def unread_role(uid: str, store: StoreDep) -> Role:
|
||||
"""Unread again: what pressing the state a role already has does."""
|
||||
try:
|
||||
return store.set_read(uid, False)
|
||||
except KeyError:
|
||||
raise HTTPException(404, f"no such role: {uid}") from None
|
||||
|
||||
|
||||
class RolesPage(BaseModel):
|
||||
"""One page of roles, and how many the same filters match in all."""
|
||||
|
||||
@@ -109,6 +127,9 @@ def list_roles(
|
||||
remote: str = "",
|
||||
days: int | None = None,
|
||||
show_muted: bool = False,
|
||||
include_read: bool = True,
|
||||
tags: list[str] = Query(default=[]),
|
||||
tag_mode: Literal["any", "all"] = "any",
|
||||
agent: int | None = None,
|
||||
order: Literal["score", "newest"] = "score",
|
||||
gated: bool = False,
|
||||
@@ -127,18 +148,47 @@ def list_roles(
|
||||
one only with `gated=1`; with `order=newest` every open role, newest
|
||||
first, with no score. Without `agent` the default agent's votes and
|
||||
hidden companies apply, the order is newest and there is no score; with
|
||||
no agent at all, every vote is None and nothing is hidden."""
|
||||
no agent at all, every vote is None and nothing is hidden.
|
||||
|
||||
`include_read` set false hides a role already marked read. `tags` is
|
||||
`?tags=a&tags=b`, kept to a role with any of them or, with
|
||||
`tag_mode=all`, every one."""
|
||||
agent_id = _agent_id(store, agent)
|
||||
by_score = agent is not None and order == "score"
|
||||
filters: dict[str, Any] = {
|
||||
"q": q or None, "company": company or None, "place": place or None,
|
||||
"function": function or None, "remote": remote or None, "days": days,
|
||||
"hide_muted": not show_muted, "agent": agent_id, "by_score": by_score,
|
||||
"hide_muted": not show_muted, "include_read": include_read, "tags": tags,
|
||||
"tag_mode": tag_mode, "agent": agent_id, "by_score": by_score,
|
||||
"gated": gated, "judged": judged or None}
|
||||
return RolesPage(items=store.roles(limit=limit, offset=offset, **filters),
|
||||
total=store.count_roles(**filters))
|
||||
|
||||
|
||||
class TagCount(BaseModel):
|
||||
"""One tag as the filter row offers it: how many open roles carry it and
|
||||
how many of those are unread."""
|
||||
|
||||
tag: str
|
||||
count: int
|
||||
unread: int
|
||||
|
||||
|
||||
class FiltersOut(BaseModel):
|
||||
tags: list[TagCount]
|
||||
|
||||
|
||||
@router.get("/filters")
|
||||
def list_filters(store: StoreDep, show_muted: bool = False,
|
||||
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
|
||||
unless `show_muted`, matching `/api/roles`."""
|
||||
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, show_muted)])
|
||||
|
||||
|
||||
# ------------------------------------------------- roles: text and summary
|
||||
|
||||
#: What the read page toasts when a posting page gave nothing readable, by
|
||||
|
||||
+15
-9
@@ -8,9 +8,11 @@ one template. `/settings` itself is Search agents.
|
||||
|
||||
Every page is a shell. Each is filled and driven by its own script under
|
||||
`static/` from the JSON routes in `web/api.py`; the Runs section of Sources
|
||||
and the Account page are shells around the modules' own elements. What the
|
||||
server renders is only what a select needs to offer, so the options cannot
|
||||
drift from what the store accepts.
|
||||
and the Account page are shells around the modules' own elements.
|
||||
`/roles/{uid}` is the Roles page again, with that role open in its reader:
|
||||
one page, so a link to a role and the role opened from the feed are the same
|
||||
screen. What the server renders is only what a select needs to offer, so the
|
||||
options cannot drift from what the store accepts.
|
||||
|
||||
Sources is one page in three sections, one per plugin: job boards (the
|
||||
`search` plugin's queries), company boards (`ats`) and the runs that read
|
||||
@@ -128,17 +130,21 @@ def page(request: Request, name: str, **context: object) -> HTMLResponse:
|
||||
@router.get("/", response_class=HTMLResponse)
|
||||
def roles(request: Request) -> HTMLResponse:
|
||||
return page(request, "roles.html", functions=FUNCTION_OPTIONS,
|
||||
remote_options=REMOTE_OPTIONS)
|
||||
remote_options=REMOTE_OPTIONS, role=None)
|
||||
|
||||
|
||||
@router.get("/roles/{uid}", response_class=HTMLResponse)
|
||||
def role(request: Request, uid: str, store: StoreDep) -> HTMLResponse:
|
||||
"""The read page of one role. A shell like the others, filled by
|
||||
`role.js`; the lookup here only makes an unknown uid a 404 page rather
|
||||
than an empty one."""
|
||||
if store.role(uid) is None:
|
||||
"""The Roles page with one role open in its reader, which is where
|
||||
opening a role from the feed puts the address bar. `roles.js` reads the
|
||||
uid from the path; the lookup here makes an unknown uid a 404 page rather
|
||||
than an empty reader, and gives the tab the role's title. `active_path`
|
||||
keeps Roles lit in the top bar."""
|
||||
found = store.role(uid)
|
||||
if found is None:
|
||||
raise HTTPException(404, f"no such role: {uid}")
|
||||
return page(request, "role.html", uid=uid)
|
||||
return page(request, "roles.html", functions=FUNCTION_OPTIONS,
|
||||
remote_options=REMOTE_OPTIONS, role=found, active_path="/")
|
||||
|
||||
|
||||
@router.get("/applications", response_class=HTMLResponse)
|
||||
|
||||
Reference in new issue
Block a user