Add a Watchlist tab for the companies the app cannot read a board of
Rate each one Yes or No apart from affinity, open its careers page with the time noted, and set a missing or wrong link in the row. Migration 15 adds companies.watch and careers_opened_at. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6f273cfdd6
commit
7dcb2c1705
11 files changed
+445
-12
No files matched your search
+52
-2
@@ -304,7 +304,8 @@ class CompanyOut(BaseModel):
|
||||
while it answers. `from_search` marks a row that exists only because a
|
||||
search listed its roles and somebody judged it (`Store.set_affinity`):
|
||||
no board, not even a detached one, and no `ats`, `careers_url` or
|
||||
`domain`, which every way of following a company writes one of."""
|
||||
`domain`, which every way of following a company writes one of.
|
||||
`watch` and `careers_opened_at` are the Watchlist's (`Company`'s)."""
|
||||
|
||||
key: str
|
||||
name: str
|
||||
@@ -317,6 +318,10 @@ class CompanyOut(BaseModel):
|
||||
ats_slug: str = ""
|
||||
careers_url: str = ""
|
||||
country: str = ""
|
||||
city: str = ""
|
||||
domain: str = ""
|
||||
watch: int | None = None
|
||||
careers_opened_at: str = ""
|
||||
failing_since: str = ""
|
||||
failing_reason: str = ""
|
||||
from_search: bool = False
|
||||
@@ -353,7 +358,8 @@ def list_companies(store: StoreDep, agent: int | None = None) -> list[CompanyOut
|
||||
subscription_id=sub_id, on=on, affinity=c.affinity,
|
||||
open_roles=counts.get(c.key, 0), ats=c.ats,
|
||||
ats_slug=c.ats_slug, careers_url=c.careers_url,
|
||||
country=c.country,
|
||||
country=c.country, city=c.city, domain=c.domain,
|
||||
watch=c.watch, careers_opened_at=c.careers_opened_at,
|
||||
failing_since=since, failing_reason=reason,
|
||||
from_search=not (c.key in ever_boarded or c.ats
|
||||
or c.careers_url or c.domain)))
|
||||
@@ -459,6 +465,50 @@ def set_affinity(key: str, body: AffinityBody, store: StoreDep,
|
||||
return AffinityOut(**company.model_dump(), score_job=job.id if job else None)
|
||||
|
||||
|
||||
class WatchBody(BaseModel):
|
||||
#: True on the Watchlist's list, False not on it, None clears the rating.
|
||||
watch: bool | None
|
||||
|
||||
|
||||
@router.post("/companies/{key}/watch")
|
||||
def set_watch(key: str, body: WatchBody, store: StoreDep) -> Company:
|
||||
"""Rate a company for the Watchlist: 1 worth checking by hand, 0 not,
|
||||
null back to unrated. Global, and apart from affinity. 404 for an
|
||||
unknown key."""
|
||||
watch = None if body.watch is None else int(body.watch)
|
||||
try:
|
||||
return store.update_company(key, watch=watch)
|
||||
except KeyError:
|
||||
raise HTTPException(404, f"no such company: {key}") from None
|
||||
|
||||
|
||||
class CareersBody(BaseModel):
|
||||
careers_url: str
|
||||
|
||||
|
||||
@router.post("/companies/{key}/careers")
|
||||
def set_careers_url(key: str, body: CareersBody, store: StoreDep) -> Company:
|
||||
"""Set or correct where a company's careers page is; "" clears it. 422
|
||||
for anything but an http(s) URL, 404 for an unknown key."""
|
||||
url = body.careers_url.strip()
|
||||
if url and not url.lower().startswith(("http://", "https://")):
|
||||
raise HTTPException(422, "careers_url must start with http:// or https://")
|
||||
try:
|
||||
return store.update_company(key, careers_url=url)
|
||||
except KeyError:
|
||||
raise HTTPException(404, f"no such company: {key}") from None
|
||||
|
||||
|
||||
@router.post("/companies/{key}/opened")
|
||||
def mark_careers_opened(key: str, store: StoreDep) -> Company:
|
||||
"""Stamp that the company's careers page was just opened from the
|
||||
Watchlist. 404 for an unknown key."""
|
||||
try:
|
||||
return store.update_company(key, careers_opened_at=store.now())
|
||||
except KeyError:
|
||||
raise HTTPException(404, f"no such company: {key}") from None
|
||||
|
||||
|
||||
# ----------------------------------------------------------------- sources
|
||||
|
||||
class SourceOut(BaseModel):
|
||||
|
||||
+8
-2
@@ -1,6 +1,6 @@
|
||||
"""The pages: two tabs, a cog, and three settings pages behind it.
|
||||
"""The pages: three tabs, a cog, and three settings pages behind it.
|
||||
|
||||
`TABS` is the top bar, Roles and Applications, and `SETTINGS` is the rail
|
||||
`TABS` is the top bar, Roles, Applications and Watchlist, and `SETTINGS` is the rail
|
||||
beside every page under the cog at `/settings/<name>`: Search agents,
|
||||
Sources, Account. `base.html` renders the first, `settings/_rail.html` the
|
||||
second, every page marks itself active by its own `path`, and adding one is
|
||||
@@ -68,6 +68,7 @@ class Tab:
|
||||
TABS: tuple[Tab, ...] = (
|
||||
Tab("/", "Roles", "roles.html"),
|
||||
Tab("/applications", "Applications", "applications.html"),
|
||||
Tab("/watchlist", "Watchlist", "watchlist.html"),
|
||||
)
|
||||
|
||||
#: The pages under the cog, in order; `settings/_rail.html` renders them.
|
||||
@@ -155,6 +156,11 @@ def applications(request: Request) -> HTMLResponse:
|
||||
return page(request, "applications.html", status_options=STATUS_OPTIONS)
|
||||
|
||||
|
||||
@router.get("/watchlist", response_class=HTMLResponse)
|
||||
def watchlist(request: Request) -> HTMLResponse:
|
||||
return page(request, "watchlist.html")
|
||||
|
||||
|
||||
@router.get("/settings", response_class=RedirectResponse)
|
||||
def settings() -> RedirectResponse:
|
||||
return RedirectResponse(SETTINGS[0].path, status_code=302)
|
||||
|
||||
Reference in new issue
Block a user