Filter seniority by a range of rungs and a track: level_from, level_to, track; From, To and Track in the rail (WP B)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ae978594b4
commit
4e390d97ca
6 files changed
+207
-71
No files matched your search
+24
-14
@@ -16,8 +16,8 @@ from pydantic import BaseModel, Field
|
||||
|
||||
from app import jobs, places
|
||||
from app.models import (
|
||||
AFFINITY, LEVELS, Agent, Application, Company, FetchTerms, Gate, Limits, Prompts, Role, RoleRow,
|
||||
HandReason, ScoredRole, Status, Subscription, Weights, company_key,
|
||||
AFFINITY, RUNGS, TRACKS, Agent, Application, Company, FetchTerms, Gate, Limits, Prompts, Role, RoleRow,
|
||||
HandReason, ScoredRole, Status, Subscription, Weights, company_key, levels_between,
|
||||
)
|
||||
from app.storage import Store
|
||||
from app.web.deps import ConfigDep, StoreDep
|
||||
@@ -78,20 +78,27 @@ def _feed_filters(
|
||||
pay: Literal["", "stated", "normalised", "stated_only"] = "",
|
||||
company_keys: list[str] = Query(default=[]),
|
||||
tokens: list[str] = Query(default=[], alias="places"),
|
||||
seniority: list[str] = Query(default=[]),
|
||||
level_from: str = "",
|
||||
level_to: str = "",
|
||||
track: str = "",
|
||||
seniority_unknown: bool = True,
|
||||
pay_unknown: bool = False,
|
||||
) -> dict[str, Any]:
|
||||
"""The feed's filters, as `Store.roles_page`, `count_roles` and
|
||||
`role_facets` take them, read from the query of `GET /api/roles` and
|
||||
`GET /api/roles/facets` alike. A place token that names nothing and a
|
||||
level outside `LEVELS` are a 422 sentence, not an empty feed."""
|
||||
`GET /api/roles/facets` alike. A place token that names nothing, a rung
|
||||
outside `RUNGS` and a track outside `TRACKS` are a 422 sentence, not an
|
||||
empty feed. The three seniority parameters become the levels between
|
||||
them (`levels_between`), which is what the store filters on."""
|
||||
for token in tokens:
|
||||
if not places.known(token):
|
||||
raise HTTPException(422, f"No place is known as {token!r}.")
|
||||
for level in seniority:
|
||||
if level not in LEVELS:
|
||||
raise HTTPException(422, f"Seniority is one of {', '.join(LEVELS)}, not {level!r}.")
|
||||
for name, rung in (("level_from", level_from), ("level_to", level_to)):
|
||||
if rung and rung not in RUNGS:
|
||||
raise HTTPException(422, f"{name} is one of {', '.join(RUNGS)}, not {rung!r}.")
|
||||
if track and track not in TRACKS:
|
||||
raise HTTPException(422, f"track is one of {', '.join(TRACKS)}, not {track!r}.")
|
||||
levels = levels_between(level_from, level_to, track) if level_from or level_to or track else []
|
||||
return {
|
||||
"q": q or None, "company": company or None, "place": place or None,
|
||||
"function": function or None, "remote": remote or None, "days": days,
|
||||
@@ -99,7 +106,7 @@ def _feed_filters(
|
||||
"tag_mode": tag_mode, "agent": _agent_id(store, agent),
|
||||
"by_score": agent is not None and order == "score", "gated": gated,
|
||||
"judged": judged or None, "pay": pay or None, "company_keys": company_keys,
|
||||
"places": tokens, "seniority": seniority, "seniority_unknown": seniority_unknown,
|
||||
"places": tokens, "seniority": list(levels), "seniority_unknown": seniority_unknown,
|
||||
"pay_unknown": pay_unknown}
|
||||
|
||||
|
||||
@@ -223,12 +230,15 @@ def list_roles(
|
||||
as well.
|
||||
|
||||
`company` and `place` are substrings, kept for links from other pages.
|
||||
The rail's fields are `company_keys` (repeated, exact keys),
|
||||
The rail's fields are `company_keys` (repeated, exact keys) and
|
||||
`places` (repeated place tokens, `app.places`: `country:DK`,
|
||||
`region:skane`, `place:malmo`, matched on whole folded words) and
|
||||
`seniority` (repeated levels), each several values joined by OR. A role
|
||||
with no level passes the seniority filter unless `seniority_unknown` is
|
||||
false. The parameters are read by `_feed_filters`.
|
||||
`region:skane`, `place:malmo`, matched on whole folded words), several
|
||||
values joined by OR, and the seniority range: `level_from` and
|
||||
`level_to` (rungs of `RUNGS`, either or both) and `track` (`ic` or
|
||||
`people`), which keep the levels between the two rungs on that track
|
||||
(`levels_between`). A role with no level passes the seniority filter
|
||||
unless `seniority_unknown` is false. The parameters are read by
|
||||
`_feed_filters`.
|
||||
|
||||
A copy of another role (`Store.rebuild_dupes`) is never a row; its kept
|
||||
role's `copies` says how many it stands for."""
|
||||
|
||||
+8
-3
@@ -41,7 +41,7 @@ from fastapi import APIRouter, HTTPException, Request
|
||||
from fastapi.responses import HTMLResponse, RedirectResponse
|
||||
from fastapi.templating import Jinja2Templates
|
||||
|
||||
from app.models import REMOTE, STATUSES
|
||||
from app.models import LADDER, REMOTE, RUNGS, STATUSES
|
||||
from app.web.deps import StoreDep
|
||||
|
||||
_ROOT = Path(__file__).resolve().parents[2]
|
||||
@@ -103,6 +103,10 @@ COUNTRY_OPTIONS = [(c, c.upper()) for c in sorted(ADZUNA_COUNTRIES)]
|
||||
REGION_OPTIONS = sorted(PLATSBANKEN_REGIONS.items(), key=lambda kv: kv[1])
|
||||
#: The ATS hosts `plugins.ats` reads, for the Follow and Set board selects.
|
||||
HOST_OPTIONS = list(HOSTS.items())
|
||||
#: The seniority ladder as `roles.js` reads it: the rungs in order, and each
|
||||
#: level's rung (an index into them) and track, so the words are `app.models`'
|
||||
#: alone. The page carries it as JSON.
|
||||
LADDER_JSON = {"rungs": list(RUNGS), "levels": {k: list(v) for k, v in LADDER.items()}}
|
||||
|
||||
|
||||
def asset(path: str) -> str:
|
||||
@@ -133,7 +137,8 @@ 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, pay_options=PAY_OPTIONS, role=None)
|
||||
remote_options=REMOTE_OPTIONS, pay_options=PAY_OPTIONS,
|
||||
ladder=LADDER_JSON, role=None)
|
||||
|
||||
|
||||
@router.get("/roles/{uid}", response_class=HTMLResponse)
|
||||
@@ -148,7 +153,7 @@ def role(request: Request, uid: str, store: StoreDep) -> HTMLResponse:
|
||||
raise HTTPException(404, f"no such role: {uid}")
|
||||
return page(request, "roles.html", functions=FUNCTION_OPTIONS,
|
||||
remote_options=REMOTE_OPTIONS, pay_options=PAY_OPTIONS,
|
||||
role=found, active_path="/")
|
||||
ladder=LADDER_JSON, role=found, active_path="/")
|
||||
|
||||
|
||||
@router.get("/applications", response_class=HTMLResponse)
|
||||
|
||||
Reference in new issue
Block a user