Recheck a board's size from the Companies row, the route and app companies size
POST /api/sources/{id}/size sizes the board again, keeps the day and queues a pull; /api/companies returns size and size_checked, and the row shows "999 roles · checked 30 Sep" with Recheck beside Change. app companies size <key> does the same from the CLI, and --missing sizes every board without a size.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a0882e9659
commit
6085017943
5 files changed
+209
-5
No files matched your search
+45
-1
@@ -3,7 +3,7 @@
|
||||
app serve [--host H] [--port P] [--reload]
|
||||
app job pull|extract|embed|score [--payload JSON]
|
||||
app worker [--workers http=8,cpu=1] [--until-idle]
|
||||
app companies seed|add|edit|checked|remove|by-hand|set-board|detach|discover|check
|
||||
app companies seed|add|edit|checked|remove|by-hand|set-board|detach|discover|check|size
|
||||
app searches add|list|remove
|
||||
app agents list|prompt
|
||||
app stages [extract|summarise on|off]
|
||||
@@ -32,6 +32,7 @@ from typing import TYPE_CHECKING, Any
|
||||
from app import config as config_mod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from app.models import Subscription
|
||||
from app.storage import Store
|
||||
|
||||
#: The one plugin this app ships lives outside the `app` package, in
|
||||
@@ -118,6 +119,10 @@ def build_parser() -> argparse.ArgumentParser:
|
||||
help="add or update the company: its board when one is readable, "
|
||||
"else the host it runs on")
|
||||
companies_sub.add_parser("check", help="report boards that do not answer, now or in the pull")
|
||||
size = companies_sub.add_parser(
|
||||
"size", help="size a company's board again, or --missing every board without a size")
|
||||
size.add_argument("key", nargs="?", default="", help="the company key, e.g. infineon")
|
||||
size.add_argument("--missing", action="store_true", help="every board with no size yet")
|
||||
|
||||
searches = sub.add_parser("searches", help="saved searches on cross-company job boards")
|
||||
searches_sub = searches.add_subparsers(dest="action", required=True)
|
||||
@@ -335,6 +340,8 @@ def run_companies(args: argparse.Namespace) -> int:
|
||||
return detach_board(store, args.key)
|
||||
if args.action == "discover":
|
||||
return discover_company(store, args.name, args.domain, add=args.add)
|
||||
if args.action == "size":
|
||||
return size_boards(store, args.key, missing=args.missing)
|
||||
return check_companies(store)
|
||||
|
||||
|
||||
@@ -503,6 +510,43 @@ def detach_board(store: Store, key: str) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
def size_boards(store: Store, key: str, *, missing: bool) -> int:
|
||||
"""`app companies size infineon`: size its board again and keep it, as
|
||||
the Companies row's Recheck does, and print the size and what a pull asks
|
||||
the board for. `--missing` sizes every board shown that has no size yet,
|
||||
a line each, and exits 1 if any did not answer. The next pull reads a
|
||||
board so; nothing is queued from here."""
|
||||
from app import jobs
|
||||
|
||||
if bool(key) == missing:
|
||||
print("companies size: name a company key, or --missing", file=sys.stderr)
|
||||
return 2
|
||||
if missing:
|
||||
subs = [s for s in store.subscriptions(source="ats") if s.show]
|
||||
known = jobs.reach.sizes(store, subs)
|
||||
subs = [s for s in subs if s.target not in known]
|
||||
else:
|
||||
sub = store.company_subscription(key)
|
||||
if sub is None or not sub.show:
|
||||
print(f"companies size: {key!r} has no board", file=sys.stderr)
|
||||
return 1
|
||||
subs = [sub]
|
||||
sized: list[tuple[Subscription, int]] = []
|
||||
for sub in subs:
|
||||
try:
|
||||
sized.append((sub, jobs.sources.size_board(store, sub.target)))
|
||||
except ValueError as exc:
|
||||
print(f"companies size: {exc}", file=sys.stderr)
|
||||
plan = jobs.reach.plan(store, [sub for sub, _size in sized])
|
||||
for sub, size in sized:
|
||||
print(json.dumps({"board": sub.target, "size": size,
|
||||
"reach": jobs.reach.line(plan, sub)}))
|
||||
dead = len(subs) - len(sized)
|
||||
if missing:
|
||||
print(f"sized {len(sized)} of {len(subs)} boards without a size")
|
||||
return 1 if dead else 0
|
||||
|
||||
|
||||
def check_companies(store: Store) -> int:
|
||||
"""`app companies check`: every `ats` board, fetched once. Prints a
|
||||
line per board that did not answer now, answered incompletely, or has
|
||||
|
||||
@@ -28,6 +28,11 @@
|
||||
* posted to `/api/sources/{id}/reach`. The wide reach (Europe) and no role
|
||||
* narrowing are the company's two overrides instead, and the board's own
|
||||
* countries win over All countries.
|
||||
*
|
||||
* Beside that line stands the board's size, set when it was added and
|
||||
* changed only by a Recheck ("999 roles · checked 30 Sep"). Recheck, beside
|
||||
* Change, sizes the board again (`/api/sources/{id}/size`) and queues a
|
||||
* pull, since the size decides whether the board is filtered.
|
||||
*/
|
||||
(function () {
|
||||
"use strict";
|
||||
@@ -67,6 +72,41 @@
|
||||
|
||||
// ---------------------------------------------------------------- the list
|
||||
|
||||
/** "30 Sep", or "30 Sep 2025" when it is not this year. A day alone
|
||||
("2026-09-30") is read as local midnight, not UTC's. */
|
||||
function checkedOn(iso) {
|
||||
const text = String(iso || "");
|
||||
const at = new Date(text.length === 10 ? `${text}T00:00` : text);
|
||||
if (Number.isNaN(at.getTime())) return "";
|
||||
const options = { day: "numeric", month: "short" };
|
||||
if (at.getFullYear() !== new Date().getFullYear()) options.year = "numeric";
|
||||
return at.toLocaleDateString("en-GB", options);
|
||||
}
|
||||
|
||||
/** The row's Recheck: size the board again, which may change what it is
|
||||
asked for, and read it with the pull that follows. */
|
||||
function recheckButton(company, rerender) {
|
||||
const button = document.createElement("button");
|
||||
button.type = "button";
|
||||
button.className = "linky";
|
||||
button.textContent = "Recheck";
|
||||
button.title = "Count the board's roles again";
|
||||
button.addEventListener("click", async () => {
|
||||
button.disabled = true;
|
||||
try {
|
||||
const result = await api(`/api/sources/${company.subscription_id}/size`,
|
||||
{ method: "POST" });
|
||||
window.toast.info(`${company.name}: ${count(result.size, "role")}, `
|
||||
+ `reads ${result.reach}. Reading now, or with the pull right after.`);
|
||||
await loadCompanies(agentId());
|
||||
rerender();
|
||||
} catch (err) {
|
||||
button.disabled = false;
|
||||
}
|
||||
});
|
||||
return button;
|
||||
}
|
||||
|
||||
function subLine(company, rerender) {
|
||||
const sub = document.createElement("span");
|
||||
sub.className = "sub";
|
||||
@@ -104,6 +144,10 @@
|
||||
}
|
||||
sub.append(` · ${count(company.open_roles, "open role")}`);
|
||||
if (company.reach) sub.append(` · reads ${company.reach}`);
|
||||
if (company.size != null) {
|
||||
const checked = checkedOn(company.size_checked);
|
||||
sub.append(` · ${count(company.size, "role")}${checked ? ` · checked ${checked}` : ""}`);
|
||||
}
|
||||
if (company.failing_since) {
|
||||
// The board has failed on every pull since then; after 21 days its
|
||||
// roles close.
|
||||
@@ -115,6 +159,10 @@
|
||||
sub.appendChild(failing);
|
||||
}
|
||||
sub.append(" ");
|
||||
if (company.subscription_id != null) {
|
||||
sub.appendChild(recheckButton(company, rerender));
|
||||
sub.append(" ");
|
||||
}
|
||||
const edit = document.createElement("button");
|
||||
edit.type = "button";
|
||||
edit.className = "linky";
|
||||
|
||||
+27
-1
@@ -491,6 +491,10 @@ class CompanyOut(BaseModel):
|
||||
#: what a pull asks its board for (`jobs.reach.line`).
|
||||
reach_params: dict[str, Any] = {}
|
||||
reach: str = ""
|
||||
#: The roles the board listed when it was last sized, and that day
|
||||
#: (ISO); None and "" before it is sized (`jobs.reach.SIZE`).
|
||||
size: int | None = None
|
||||
size_checked: str = ""
|
||||
|
||||
|
||||
def _company_boards(store: Store) -> dict[str, tuple[int, str, bool, str]]:
|
||||
@@ -534,7 +538,10 @@ def _company_outs(store: Store, agent: int | None) -> list[CompanyOut]:
|
||||
all_roles=bool(c.all_roles),
|
||||
reach_params={k: v for k, v in (sub.params if sub else {}).items()
|
||||
if k in jobs.reach.OVERRIDE_KEYS},
|
||||
reach=jobs.reach.line(plan, sub) if sub else ""))
|
||||
reach=jobs.reach.line(plan, sub) if sub else "",
|
||||
size=plan.sizes.get(target) if sub else None,
|
||||
size_checked=store.state.get(
|
||||
jobs.reach.SIZE_CHECKED + target, "") if sub else ""))
|
||||
return out
|
||||
|
||||
|
||||
@@ -897,6 +904,25 @@ def set_reach(sub_id: int, body: ReachBody, store: StoreDep) -> dict[str, Any]:
|
||||
"reach": jobs.reach.line(jobs.reach.plan(store, [sub]), sub)}
|
||||
|
||||
|
||||
@router.post("/sources/{sub_id}/size")
|
||||
def recheck_size(sub_id: int, store: StoreDep, queue: QueueDep) -> dict[str, Any]:
|
||||
"""Size a board again, the one way its size changes once it was added
|
||||
(`jobs.sources.size_board`): its reach may change with it, so a pull is
|
||||
queued right after, as the other routes that change what is read do. 422
|
||||
when the board does not answer; the size it had stays."""
|
||||
sub = store.subscription(sub_id)
|
||||
if sub is None or sub.source != "ats":
|
||||
raise HTTPException(404, f"no such board: {sub_id}")
|
||||
try:
|
||||
size = jobs.sources.size_board(store, sub.target)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(422, str(exc)) from exc
|
||||
queue.enqueue("pull")
|
||||
checked = store.state.get(jobs.reach.SIZE_CHECKED + sub.target, "")
|
||||
return {"size": size, "size_checked": checked,
|
||||
"reach": jobs.reach.line(jobs.reach.plan(store, [sub]), sub)}
|
||||
|
||||
|
||||
class ReaderOut(BaseModel):
|
||||
"""What a reader declares (`plugins/readers/_contract.py`), for the
|
||||
Sources page: `filters` holds only the dimensions it filters."""
|
||||
|
||||
Reference in new issue
Block a user