Drop pruning boards by region: a fix for the US seed, and a wrong one
`app companies prune`, `/api/prune` and the Sources disclosure switched off every board with no open role in a region. It existed because the first seed was 186 US boards; the European seed makes it moot, and it was wrong on its own terms: a board with no European role today (a company between openings, or a fetch that timed out) was switched off for good. A company that hires nowhere near should not be in the list, and a ranking's country gate handles the rest. `EUROPE` in models had no other reader and goes with it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
3aee48997c
commit
e602eb3388
12 files changed
+11
-233
No files matched your search
@@ -18,7 +18,6 @@ if str(ROOT) not in sys.path:
|
||||
from desk.models import Item # noqa: E402
|
||||
from plugins import search # noqa: E402
|
||||
from plugins.search import SearchSource # noqa: E402
|
||||
from app import cli # noqa: E402
|
||||
from app.config import SearchSeed # noqa: E402
|
||||
from app.jobs import pull # noqa: E402
|
||||
from app.models import country_of # noqa: E402
|
||||
@@ -222,35 +221,6 @@ def test_seed_searches_imports_once(store: Store) -> None:
|
||||
|
||||
# -------------------------------------------------------------------- cli
|
||||
|
||||
def test_prune_unsubscribes_boards_with_no_role_in_the_region(
|
||||
store: Store, capsys: pytest.CaptureFixture[str]) -> None:
|
||||
def board(slug: str, *places: str) -> int:
|
||||
sub = store.add_subscription("ats", f"greenhouse:{slug}", label=slug, company=slug,
|
||||
board="greenhouse")
|
||||
for n, place in enumerate(places):
|
||||
it = Item(source_id=f"greenhouse:{slug}:{n}", location="https://x.example/1",
|
||||
title=f"Engineer {n}", body="", raw={"company": slug, "place": place})
|
||||
it.source = "ats"
|
||||
store.upsert_role(it, sub)
|
||||
return sub.id
|
||||
|
||||
us = board("usonly", "Boston, MA", "Remote - US")
|
||||
both = board("both", "San Francisco, CA", "London, UK")
|
||||
vague = board("vague", "Remote", "Hybrid")
|
||||
|
||||
cli.prune_companies(store, "europe", apply=False)
|
||||
assert "usonly" in capsys.readouterr().out
|
||||
assert len(store.subscriptions(source="ats", fetchable=True)) == 3
|
||||
|
||||
cli.prune_companies(store, "europe", apply=True)
|
||||
fetchable = {s.id for s in store.subscriptions(source="ats", fetchable=True)}
|
||||
assert fetchable == {both, vague}
|
||||
assert all(r.subscription_id != us for r in store.roles())
|
||||
|
||||
cli.prune_companies(store, "DK,EU", apply=True)
|
||||
assert {s.id for s in store.subscriptions(source="ats", fetchable=True)} == {vague}
|
||||
|
||||
|
||||
def test_search_source_stamps_complete_and_ids(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
_stub_search(monkeypatch, ["h1"], complete=True)
|
||||
source = SearchSource({"searches": [{"url": "jobindex:cph", "label": "Copenhagen",
|
||||
|
||||
+1
-19
@@ -638,11 +638,10 @@ def test_the_sources_page_has_a_section_per_plugin(client: TestClient) -> None:
|
||||
assert 'id="searches-list"' in page and 'id="search-form"' in page
|
||||
assert 'value="1" selected>Region Hovedstaden' in page
|
||||
assert "job board" in page.lower() and "saved search" not in page.lower()
|
||||
# Company boards: the follow form, the agent select, the list, the prune tool.
|
||||
# Company boards: the follow form, the agent select, the list.
|
||||
assert 'id="companies-list"' in page and 'id="c-agent"' in page
|
||||
assert 'id="b-host"' in page and 'id="b-slug"' in page and 'id="b-name"' in page
|
||||
assert '<option value="greenhouse">' in page and '<option value="personio">' in page
|
||||
assert 'id="prune-form"' in page and "Switch off boards with no roles in a region" in page
|
||||
boards = page[page.index('id="company-boards"'):page.index('id="runs"')].lower()
|
||||
assert "hidden" in boards and "mute" not in boards
|
||||
# Runs: Pull now, the queue's elements, one stage at a time, the log.
|
||||
@@ -876,23 +875,6 @@ def test_a_board_is_followed_only_if_it_answers(
|
||||
assert bad.status_code == 422 and "host:slug" in bad.json()["detail"]
|
||||
|
||||
|
||||
def test_prune_previews_then_switches_off(client: TestClient, store: Store) -> None:
|
||||
us = store.add_subscription("ats", "greenhouse:us", label="US", company="US",
|
||||
board="greenhouse")
|
||||
dk = store.add_subscription("ats", "greenhouse:dk", label="DK", company="DK",
|
||||
board="greenhouse")
|
||||
store.upsert_role(posting("1", company="US", place="Boston, MA"), us)
|
||||
store.upsert_role(posting("2", company="DK", place="Copenhagen"), dk)
|
||||
|
||||
preview = client.get("/api/prune", params={"region": "DK,EU"}).json()
|
||||
assert [b["label"] for b in preview["boards"]] == ["US"]
|
||||
assert len(store.subscriptions(source="ats", fetchable=True)) == 2
|
||||
|
||||
done = client.post("/api/prune", json={"region": "DK,EU"}).json()
|
||||
assert (done["pruned"], done["roles_closed"], done["boards_left"]) == (1, 1, 1)
|
||||
assert client.get("/api/prune", params={"region": " "}).status_code == 422
|
||||
|
||||
|
||||
# ------------------------------------------------- roles: text and summary
|
||||
|
||||
def test_the_posting_text_is_fetched_once(
|
||||
|
||||
Reference in new issue
Block a user