Carry limits and board_open on companies, and the reader traits
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
8b07f9a602
commit
439fc94e78
1 file changed
+29
-3
+29
-3
@@ -487,6 +487,11 @@ class CompanyOut(BaseModel):
|
||||
#: (ISO); None and "" before it is sized (`jobs.reach.SIZE`).
|
||||
size: int | None = None
|
||||
size_checked: str = ""
|
||||
#: What limits the board's read, in words (`jobs.limits.WORDS`), and the
|
||||
#: board's own open roles, which `open_roles` also counts the searches'
|
||||
#: roles beside; None with no board.
|
||||
limits: list[str] = []
|
||||
board_open: int | None = None
|
||||
|
||||
|
||||
def _company_boards(store: Store) -> dict[str, tuple[int, str, bool, str]]:
|
||||
@@ -505,18 +510,27 @@ def _company_boards(store: Store) -> dict[str, tuple[int, str, bool, str]]:
|
||||
|
||||
|
||||
def _company_outs(store: Store, agent: int | None) -> list[CompanyOut]:
|
||||
from plugins import readers
|
||||
|
||||
boards = _company_boards(store)
|
||||
ever_boarded = {company_key(s.company) for s in store.subscriptions(source="ats")}
|
||||
counts = store.open_role_counts()
|
||||
failing = jobs.pull.failing_boards(store)
|
||||
subs = {s.id: s for s in store.subscriptions(source="ats")}
|
||||
plan = jobs.reach.plan(store, subs.values())
|
||||
state = jobs.limits.state_of(store)
|
||||
per_board = jobs.limits.texts(store)
|
||||
out = []
|
||||
for c in store.companies(agent):
|
||||
sub_id, host, on, target = boards.get(c.key, (None, "", None, ""))
|
||||
since, reason = failing.get(target, ("", ""))
|
||||
sub = subs.get(sub_id) if sub_id is not None else None
|
||||
from_search = jobs.sources.known_from_search_only(c, ever_boarded)
|
||||
module = readers.HOSTS.get(target.partition(":")[0]) if sub else None
|
||||
reach_line = jobs.reach.line(plan, sub) if sub else ""
|
||||
board = per_board.get(sub_id, jobs.limits.Texts(0, 0)) if sub else None
|
||||
found = jobs.limits.words(module, state, target, sub, plan.sizes.get(target), plan=plan,
|
||||
line=reach_line, counts=board) if module and sub else []
|
||||
out.append(CompanyOut(key=c.key, name=c.name, notes=c.notes, board=host,
|
||||
target=target,
|
||||
subscription_id=sub_id, on=on, affinity=c.affinity,
|
||||
@@ -531,10 +545,11 @@ 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=reach_line,
|
||||
size=plan.sizes.get(target) if sub else None,
|
||||
size_checked=store.state.get(
|
||||
jobs.reach.SIZE_CHECKED + target, "") if sub else ""))
|
||||
jobs.reach.SIZE_CHECKED + target, "") if sub else "",
|
||||
limits=found, board_open=board.open if board else None))
|
||||
return out
|
||||
|
||||
|
||||
@@ -931,6 +946,14 @@ class ReaderOut(BaseModel):
|
||||
filters: dict[str, str]
|
||||
places: str
|
||||
robots: str
|
||||
#: `Reads.complete`, `page_size`, `ceiling`, `teaser`, `empty`, and
|
||||
#: `fields` as a dict: the traits `jobs.limits` turns into words.
|
||||
complete: str
|
||||
page_size: int | None = None
|
||||
ceiling: int | None = None
|
||||
teaser: bool = False
|
||||
empty: str = "trusted"
|
||||
fields: dict[str, str] = {}
|
||||
|
||||
|
||||
@router.get("/readers")
|
||||
@@ -943,7 +966,10 @@ def list_readers() -> list[ReaderOut]:
|
||||
return [ReaderOut(name=m.NAME, label=m.LABEL, scope=m.READS.scope,
|
||||
listing=m.READS.listing, text=m.READS.text,
|
||||
filters=m.READS.filters.declared(), places=m.READS.places,
|
||||
robots=m.READS.robots)
|
||||
robots=m.READS.robots, complete=m.READS.complete,
|
||||
page_size=m.READS.page_size, ceiling=m.READS.ceiling,
|
||||
teaser=m.READS.teaser, empty=m.READS.empty,
|
||||
fields=m.READS.fields.model_dump())
|
||||
for m in sorted(found, key=lambda m: (m.READS.scope != "board", m.LABEL.lower()))]
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user