Tag a company All roles to read its big boards with the agents' wide reach; favourite scores only
Migration 21 adds companies.all_roles, tags every favourite of any agent and each company whose board had params {"reach": "all"} (logged per board, the param removed). reach.plan reads a tagged company's boards with the union of the enabled agents' require reach and the base reach; favourite no longer widens the fetch. POST /api/companies/{key}/all-roles sets it and queues a pull when on. The Companies list, the reader and the company strip draw the toggle beside the affinity buttons, the list filters on it, and the board's reach editor drops its All roles option.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8d9a059e24
commit
5d5b7e7d3f
20 files changed
+422
-124
No files matched your search
+35
-6
@@ -67,10 +67,6 @@ def test_a_boards_own_reach_is_kept_in_its_params_and_wins(
|
||||
assert sub.params == {"note": "kept", "countries": ["DE", "SE"], "remote": True}
|
||||
assert _row(client)["reach_params"] == {"countries": ["DE", "SE"], "remote": True}
|
||||
|
||||
res = client.post(f"/api/sources/{bosch}/reach", json={"mode": "all"})
|
||||
assert res.json()["reach"] == "all roles · set here"
|
||||
assert store.subscription(bosch).params == {"note": "kept", "reach": "all"} # type: ignore[union-attr]
|
||||
|
||||
res = client.post(f"/api/sources/{bosch}/reach", json={"mode": "agents"})
|
||||
assert res.json()["reach"] == "DK · agents"
|
||||
assert store.subscription(bosch).params == {"note": "kept"} # type: ignore[union-attr]
|
||||
@@ -81,6 +77,7 @@ def test_a_boards_own_reach_is_kept_in_its_params_and_wins(
|
||||
({"mode": "own", "countries": ["XX"]}, 422),
|
||||
({"mode": "own", "countries": ["EU"]}, 422),
|
||||
({"mode": "nowhere"}, 422),
|
||||
({"mode": "all"}, 422), # every role is the company's tag now
|
||||
])
|
||||
def test_a_reach_that_names_nothing_is_refused(
|
||||
client: TestClient, bosch: int, body: dict[str, object], status: int) -> None:
|
||||
@@ -90,8 +87,40 @@ def test_a_reach_that_names_nothing_is_refused(
|
||||
def test_a_search_or_an_unknown_board_has_no_reach(client: TestClient, store: Store) -> None:
|
||||
search = store.add_subscription("search", "jobindex:x", label="X", board="jobindex",
|
||||
params={"q": "python"})
|
||||
assert client.post(f"/api/sources/{search.id}/reach", json={"mode": "all"}).status_code == 404
|
||||
assert client.post("/api/sources/999/reach", json={"mode": "all"}).status_code == 404
|
||||
assert client.post(f"/api/sources/{search.id}/reach",
|
||||
json={"mode": "agents"}).status_code == 404
|
||||
assert client.post("/api/sources/999/reach", json={"mode": "agents"}).status_code == 404
|
||||
|
||||
|
||||
#: Every state a job may be in, for a "was one queued at all" check that does
|
||||
#: not race a background worker draining it.
|
||||
_ANY_STATE = ("queued", "running", "done", "failed", "cancelled")
|
||||
|
||||
|
||||
def test_the_all_roles_tag_reads_the_wide_reach_and_on_queues_a_pull(
|
||||
client: TestClient, app: FastAPI, store: Store, bosch: int) -> None:
|
||||
queue = app.state.queue
|
||||
res = client.post("/api/companies/bosch/all-roles", json={"on": True})
|
||||
assert res.status_code == 200, res.text
|
||||
assert res.json()["all_roles"] == 1
|
||||
# On reopens roles, so it queues a pull as switching a board on does.
|
||||
assert queue.jobs.last("pull", states=_ANY_STATE) is not None
|
||||
row = _row(client)
|
||||
# Wolf requires no place, so the wide reach is everywhere.
|
||||
assert (row["all_roles"], row["reach"]) == (True, "all roles · company tag")
|
||||
# A board's own countries win over the tag.
|
||||
client.post(f"/api/sources/{bosch}/reach", json={"mode": "own", "countries": ["DE"]})
|
||||
assert _row(client)["reach"] == "DE · set here"
|
||||
|
||||
|
||||
def test_turning_the_tag_off_queues_nothing(
|
||||
client: TestClient, app: FastAPI, store: Store, bosch: int) -> None:
|
||||
store.set_all_roles("bosch", True)
|
||||
res = client.post("/api/companies/bosch/all-roles", json={"on": False})
|
||||
assert res.status_code == 200 and res.json()["all_roles"] == 0
|
||||
assert app.state.queue.jobs.last("pull", states=_ANY_STATE) is None
|
||||
assert _row(client)["reach"] == "DK · agents"
|
||||
assert client.post("/api/companies/nobody/all-roles", json={"on": True}).status_code == 404
|
||||
|
||||
|
||||
def test_the_readers_are_listed_with_what_they_declare(client: TestClient) -> None:
|
||||
|
||||
Reference in new issue
Block a user