Lead a role in several cities with the one nearest the viewing agent, in the row, the reader and the posting link

Places are ordered in tiers off the agent's gates (the any group, then the require scope, then the rest), and within a tier by the home the any group gives, since the gazetteer holds no coordinates. GET /api/roles and /api/roles/{uid} carry place_texts, lead_place and lead_url for the roles served; the gates and the dupes rule are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-10-04 08:15:26 +02:00
1 parent ac4cdb8a48
commit fb24c8e4c9
8 files changed
+277 -29

No files matched your search

+33
View File
@@ -301,3 +301,36 @@ def test_switching_a_board_off_shows_its_roles_copies_at_once(store: Store) -> N
set_fetch(store, sub.id, False)
assert dup_of(store) == {board.uid: None, search.uid: None}
def test_a_role_in_several_cities_leads_with_the_one_nearest_the_agent(store: Store) -> None:
"""Mistral posts one role per city. For an agent kept to Europe the kept
Montréal role leads with Paris, in the row and the reader, and opens the
Paris copy; without an agent the host's order stands."""
from app import prep
from app.models import Gate
items = [role(c, company="Mistral AI", place=p, board="ashby") for c, p in (
("mtl", "Montréal"), ("nyc", "New York"), ("par", "Paris"))]
for item in items:
store.upsert_role(item)
prep.run(store)
kept = kept_of(store, *items)
agent = store.save_agent("A", gates=[
Gate(field="country", values=["FR", "DK", "EU"], mode="require"),
Gate(field="country", values=["DK"], mode="any")])
got = store.role(kept, agent.id)
assert got is not None
own = next(p.text for p in got.places if not p.url)
assert own != "Paris"
assert (got.lead_place, got.lead_url) == ("Paris", "https://jobs.example/par")
assert got.places[0].text == "Paris"
(row,) = store.roles_page(agent=agent.id, by_score=False)
assert (row.place, row.lead_place, row.lead_url) == ("Paris +2", "Paris", got.lead_url)
assert row.place_texts[0] == "Paris" and len(row.place_texts) == 3
plain = store.role(kept)
assert plain is not None
assert plain.lead_place == own and plain.lead_url == ""
(row,) = store.roles_page(by_score=False)
assert row.place == f"{own} +2" and row.lead_url == ""