Per-agent ranking: votes, affinity and a taste term; settings are three sub-tabs
Votes on roles and company affinity move to role_votes and agent_companies, one row per search agent, so two agents rank the same roles differently. The score gains taste, the cosine to mean(liked) - mean(passed) of the agent's votes, as newsdesk ranks articles. The API takes agent on roles, votes and companies and falls back to the default agent, the enabled one with the lowest id. Settings become Search agents (a list again, with New and Delete), Sources (job boards, company boards and runs with the message log, one section per plugin) and Account. Old paths answer 301 to their section. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
515d2250fc
commit
a0772519b3
28 files changed
+1461
-668
No files matched your search
+46
-47
@@ -1,26 +1,32 @@
|
||||
"""The pages: two tabs, a cog, and six settings pages behind it.
|
||||
"""The pages: two tabs, a cog, and three settings pages behind it.
|
||||
|
||||
`TABS` is the top bar, Roles and Applications, and `SETTINGS` is the row of
|
||||
sub-tabs under the cog at `/settings/<name>`: the setup pages first (Ranking,
|
||||
Searches, Companies), the system ones after (Pulls, Messages, Account).
|
||||
sub-tabs under the cog at `/settings/<name>`: Search agents, Sources, Account.
|
||||
`base.html` renders the first, `settings/_tabs.html` the second, every page
|
||||
marks itself active by its own `path`, and adding one is one entry here plus
|
||||
one template. `/settings` itself is Ranking.
|
||||
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`; Pulls and Account 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.
|
||||
`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.
|
||||
|
||||
The pages that were tabs before the settings shell (`/agents`, `/companies`,
|
||||
`/sources`, `/jobs`, `/schedules`, `/messages`, `/account`) answer 301 to
|
||||
their new place, query string kept, so a bookmark still lands.
|
||||
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
|
||||
them, with the message log at the end. Its scripts are the ones the sections
|
||||
had as pages of their own, each guarding on its own root element.
|
||||
|
||||
Every path a page has had before (`/agents`, `/companies`, `/sources`,
|
||||
`/jobs`, `/schedules`, `/messages`, `/account`, and the six sub-tabs the
|
||||
settings shell started with) answers 301 to its place now, query string
|
||||
kept, so a bookmark still lands. A merged page's old path lands on its
|
||||
section's anchor.
|
||||
|
||||
`FUNCTIONS` is `plugins.ats`'s, not `app`'s: the nine job functions are the
|
||||
classifier's vocabulary, and this reaches `plugins/` the same way `app.cli`
|
||||
does, since a plugin is app-agnostic and never reaches back into `app`. The
|
||||
Jobindex areas and Adzuna countries on the Searches page come from
|
||||
Jobindex areas and Adzuna countries on the Sources page come from
|
||||
`plugins.search` for the same reason.
|
||||
"""
|
||||
|
||||
@@ -64,22 +70,25 @@ TABS: tuple[Tab, ...] = (
|
||||
|
||||
#: The sub-tabs under the cog, in order; `settings/_tabs.html` renders them.
|
||||
SETTINGS: tuple[Tab, ...] = (
|
||||
Tab("/settings/ranking", "Ranking", "settings/ranking.html"),
|
||||
Tab("/settings/searches", "Searches", "settings/searches.html"),
|
||||
Tab("/settings/companies", "Companies", "settings/companies.html"),
|
||||
Tab("/settings/pulls", "Pulls", "settings/pulls.html"),
|
||||
Tab("/settings/messages", "Messages", "settings/messages.html"),
|
||||
Tab("/settings/agents", "Search agents", "settings/agents.html"),
|
||||
Tab("/settings/sources", "Sources", "settings/sources.html"),
|
||||
Tab("/settings/account", "Account", "settings/account.html"),
|
||||
)
|
||||
|
||||
#: Where each page that used to be a tab lives now.
|
||||
#: Where each page that used to be a tab or a sub-tab lives now. The fragment
|
||||
#: is the section on the merged page; a browser keeps it across the 301.
|
||||
MOVED: dict[str, str] = {
|
||||
"/agents": "/settings/ranking",
|
||||
"/companies": "/settings/companies",
|
||||
"/sources": "/settings/searches",
|
||||
"/jobs": "/settings/pulls",
|
||||
"/schedules": "/settings/pulls",
|
||||
"/messages": "/settings/messages",
|
||||
"/agents": "/settings/agents",
|
||||
"/settings/ranking": "/settings/agents",
|
||||
"/companies": "/settings/sources#company-boards",
|
||||
"/settings/companies": "/settings/sources#company-boards",
|
||||
"/sources": "/settings/sources#job-boards",
|
||||
"/settings/searches": "/settings/sources#job-boards",
|
||||
"/jobs": "/settings/sources#runs",
|
||||
"/schedules": "/settings/sources#runs",
|
||||
"/settings/pulls": "/settings/sources#runs",
|
||||
"/messages": "/settings/sources#messages",
|
||||
"/settings/messages": "/settings/sources#messages",
|
||||
"/account": "/settings/account",
|
||||
}
|
||||
|
||||
@@ -142,42 +151,32 @@ def settings() -> RedirectResponse:
|
||||
return RedirectResponse(SETTINGS[0].path, status_code=302)
|
||||
|
||||
|
||||
@router.get("/settings/ranking", response_class=HTMLResponse)
|
||||
def ranking(request: Request) -> HTMLResponse:
|
||||
return page(request, "settings/ranking.html")
|
||||
@router.get("/settings/agents", response_class=HTMLResponse)
|
||||
def agents(request: Request) -> HTMLResponse:
|
||||
return page(request, "settings/agents.html")
|
||||
|
||||
|
||||
@router.get("/settings/searches", response_class=HTMLResponse)
|
||||
def searches(request: Request) -> HTMLResponse:
|
||||
return page(request, "settings/searches.html", areas=AREA_OPTIONS,
|
||||
@router.get("/settings/sources", response_class=HTMLResponse)
|
||||
def sources(request: Request) -> HTMLResponse:
|
||||
return page(request, "settings/sources.html", areas=AREA_OPTIONS,
|
||||
countries=COUNTRY_OPTIONS)
|
||||
|
||||
|
||||
@router.get("/settings/companies", response_class=HTMLResponse)
|
||||
def companies(request: Request) -> HTMLResponse:
|
||||
return page(request, "settings/companies.html")
|
||||
|
||||
|
||||
@router.get("/settings/pulls", response_class=HTMLResponse)
|
||||
def pulls(request: Request) -> HTMLResponse:
|
||||
return page(request, "settings/pulls.html")
|
||||
|
||||
|
||||
@router.get("/settings/messages", response_class=HTMLResponse)
|
||||
def messages(request: Request) -> HTMLResponse:
|
||||
return page(request, "settings/messages.html")
|
||||
|
||||
|
||||
@router.get("/settings/account", response_class=HTMLResponse)
|
||||
def account(request: Request) -> HTMLResponse:
|
||||
return page(request, "settings/account.html")
|
||||
|
||||
|
||||
def _moved(to: str) -> Callable[[Request], RedirectResponse]:
|
||||
"""A 301 to `to`, carrying the query string, so `/agents?x=1` keeps it."""
|
||||
"""A 301 to `to`, carrying the query string, so `/agents?x=1` keeps it.
|
||||
The query goes before `to`'s fragment, if it has one, or the browser
|
||||
would read `#runs?x=1` as one fragment."""
|
||||
path, _, fragment = to.partition("#")
|
||||
def redirect(request: Request) -> RedirectResponse:
|
||||
query = request.url.query
|
||||
return RedirectResponse(f"{to}?{query}" if query else to, status_code=301)
|
||||
target = f"{path}?{query}" if query else path
|
||||
return RedirectResponse(f"{target}#{fragment}" if fragment else target,
|
||||
status_code=301)
|
||||
return redirect
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user