Summarise every saved or liked role whatever its rank, queue it at once on save or like, and shorten the order labels to Agent match, CV match and Newest so they fit one line

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Sonnet 5.5 committed 2026-10-03 23:14:12 +02:00
1 parent 1d0a4c37f2
commit ee8e450640
20 files changed
+208 -60

No files matched your search

+57
View File
@@ -1807,3 +1807,60 @@ def test_suggest_companies_matches_through_an_alias(client: TestClient, store: S
for q in ("orsted", "ørsted", "dong"):
res = client.get("/api/suggest/companies", params={"q": q})
assert [(c["key"], c["name"]) for c in res.json()] == [("ørsted", "Ørsted")]
def _summary_jobs(queue: Any) -> list[Any]:
return [j for j in queue.jobs.snapshot().queued if j.kind == "summarise_batch"]
def test_saving_or_liking_a_role_queues_its_summary_once(
app: FastAPI, store: Store, queue: Any, monkeypatch: pytest.MonkeyPatch) -> None:
"""With the stage on, a model reachable and the role without a summary, the
star and an up vote from an enabled agent queue a batch of that uid under
the button's key, so double taps and both together are one job."""
from desk.tools import agent
monkeypatch.setattr(agent, "backend", lambda settings: "api")
app.state.config.summarise.enabled = True
client = TestClient(app)
upsert(store, posting("1"))
upsert(store, posting("2"))
saved, liked = posting("1").uid, posting("2").uid
owner = store.save_agent("A", "python")
assert client.post("/api/applications", json={"role_uid": saved}).status_code == 201
client.post("/api/applications", json={"role_uid": saved})
assert [j.payload for j in _summary_jobs(queue)] == [{"uids": [saved]}]
assert client.post(f"/api/roles/{liked}/vote", json={"value": -1, "agent": owner.id}).status_code == 200
assert len(_summary_jobs(queue)) == 1
client.post(f"/api/roles/{liked}/vote", json={"value": 1, "agent": owner.id})
client.post(f"/api/roles/{liked}/vote", json={"value": 1, "agent": owner.id})
assert sorted(j.payload["uids"][0] for j in _summary_jobs(queue)) == sorted([saved, liked])
# The button shares the key.
assert client.post(f"/api/roles/{liked}/summarise").status_code == 202
assert len(_summary_jobs(queue)) == 2
def test_saving_queues_no_summary_when_the_stage_is_off_or_it_has_one(
app: FastAPI, store: Store, queue: Any, monkeypatch: pytest.MonkeyPatch) -> None:
from desk.tools import agent
monkeypatch.setattr(agent, "backend", lambda settings: "api")
client = TestClient(app)
upsert(store, posting("1"))
upsert(store, posting("2"))
off, done = posting("1").uid, posting("2").uid
client.post("/api/applications", json={"role_uid": off})
assert _summary_jobs(queue) == []
app.state.config.summarise.enabled = True
store.set_summary(done, "Already written, long enough.")
client.post("/api/applications", json={"role_uid": done})
assert _summary_jobs(queue) == []
monkeypatch.setattr(agent, "backend", lambda settings: "")
store.upsert_role(posting("3"))
client.post("/api/applications", json={"role_uid": posting("3").uid})
assert _summary_jobs(queue) == []