Sort the by-hand list by the Watchlist's careers_opened_at and print the watch rating
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1a2689e08d
commit
161e89c955
3 files changed
+28
-20
No files matched your search
+11
-7
@@ -409,12 +409,14 @@ def edit_company(store: Store, args: argparse.Namespace) -> int:
|
|||||||
|
|
||||||
|
|
||||||
def company_checked(store: Store, key: str) -> int:
|
def company_checked(store: Store, key: str) -> int:
|
||||||
"""`app companies checked acme`: its careers page was looked at just now."""
|
"""`app companies checked acme`: its careers page was looked at just now,
|
||||||
|
which the Watchlist keeps as `careers_opened_at`, the same stamp opening
|
||||||
|
the page from there sets."""
|
||||||
if store.company(key) is None:
|
if store.company(key) is None:
|
||||||
print(f"companies checked: no company {key!r}", file=sys.stderr)
|
print(f"companies checked: no company {key!r}", file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
company = store.update_company(key, checked_at=store.now())
|
company = store.update_company(key, careers_opened_at=store.now())
|
||||||
print(json.dumps({"key": key, "checked_at": company.checked_at}))
|
print(json.dumps({"key": key, "careers_opened_at": company.careers_opened_at}))
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
@@ -437,14 +439,16 @@ def remove_company(store: Store, key: str) -> int:
|
|||||||
|
|
||||||
def list_by_hand(store: Store) -> int:
|
def list_by_hand(store: Store) -> int:
|
||||||
"""`app companies by-hand`: the companies with no board shown that are not
|
"""`app companies by-hand`: the companies with no board shown that are not
|
||||||
known from a search only, one line each, never checked first and then the
|
known from a search only, one line each, never opened first and then the
|
||||||
longest ago, as the Sources page lists them; see `jobs.sources.by_hand`."""
|
longest ago; `watch` is the Watchlist's rating, yes, no or a dash for
|
||||||
|
unrated. See `jobs.sources.by_hand`."""
|
||||||
from app import jobs
|
from app import jobs
|
||||||
|
|
||||||
rows = jobs.sources.by_hand(store)
|
rows = jobs.sources.by_hand(store)
|
||||||
for c in rows:
|
for c in rows:
|
||||||
checked = c.checked_at[:10] or "never"
|
watch = "-" if c.watch is None else "yes" if c.watch else "no"
|
||||||
print(f"{c.name:30} {c.hand_reason or '-':8} {checked:10} {c.careers_url}")
|
opened = c.careers_opened_at[:10] or "never"
|
||||||
|
print(f"{c.name:30} {c.hand_reason or '-':8} {watch:4} {opened:10} {c.careers_url}")
|
||||||
print(f"{len(rows)} by hand")
|
print(f"{len(rows)} by hand")
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -169,13 +169,13 @@ def known_from_search_only(company: Company, ever_boarded: set[str]) -> bool:
|
|||||||
|
|
||||||
def by_hand(store: Store) -> list[Company]:
|
def by_hand(store: Store) -> list[Company]:
|
||||||
"""The list checked by hand: companies with no board shown that are not
|
"""The list checked by hand: companies with no board shown that are not
|
||||||
known from a search only. Never checked first, then the longest ago; the
|
known from a search only. Never opened first, then the longest ago
|
||||||
name breaks a tie."""
|
(`careers_opened_at`, the Watchlist's stamp); the name breaks a tie."""
|
||||||
boards = store.company_boards()
|
boards = store.company_boards()
|
||||||
ever_boarded = {company_key(s.company) for s in store.subscriptions(source="ats")}
|
ever_boarded = {company_key(s.company) for s in store.subscriptions(source="ats")}
|
||||||
rows = [c for c in store.companies()
|
rows = [c for c in store.companies()
|
||||||
if c.key not in boards and not known_from_search_only(c, ever_boarded)]
|
if c.key not in boards and not known_from_search_only(c, ever_boarded)]
|
||||||
return sorted(rows, key=lambda c: (c.checked_at, c.name.casefold()))
|
return sorted(rows, key=lambda c: (c.careers_opened_at, c.name.casefold()))
|
||||||
|
|
||||||
|
|
||||||
class Conflict(ValueError):
|
class Conflict(ValueError):
|
||||||
|
|||||||
+14
-10
@@ -373,14 +373,14 @@ def test_remove_company_refuses_a_board_shown_and_open_roles(
|
|||||||
sources.remove_company(store, "open")
|
sources.remove_company(store, "open")
|
||||||
|
|
||||||
|
|
||||||
def test_by_hand_lists_the_unboarded_never_checked_first(
|
def test_by_hand_lists_the_unboarded_never_opened_first(
|
||||||
store: Store, boards: Boards) -> None:
|
store: Store, boards: Boards) -> None:
|
||||||
sources.add_by_hand(store, "Zeta")
|
sources.add_by_hand(store, "Zeta")
|
||||||
sources.add_by_hand(store, "Beta")
|
sources.add_by_hand(store, "Beta")
|
||||||
sources.add_by_hand(store, "Old")
|
sources.add_by_hand(store, "Old")
|
||||||
sources.add_by_hand(store, "Recent")
|
sources.add_by_hand(store, "Recent")
|
||||||
store.update_company("old", checked_at="2026-08-01T00:00:00+00:00")
|
store.update_company("old", careers_opened_at="2026-08-01T00:00:00+00:00")
|
||||||
store.update_company("recent", checked_at="2026-09-20T00:00:00+00:00")
|
store.update_company("recent", careers_opened_at="2026-09-20T00:00:00+00:00")
|
||||||
sources.set_board(store, "read", "greenhouse:acme", name="Read") # a board: not listed
|
sources.set_board(store, "read", "greenhouse:acme", name="Read") # a board: not listed
|
||||||
store.add_company("Pleo", key="pleo", ats="teamtailor") # unread, no reason: listed
|
store.add_company("Pleo", key="pleo", ats="teamtailor") # unread, no reason: listed
|
||||||
store.add_company("Quiet", key="quiet") # from a search only
|
store.add_company("Quiet", key="quiet") # from a search only
|
||||||
@@ -486,8 +486,8 @@ def test_cli_edit_checked_and_remove_a_company_by_hand(
|
|||||||
assert "no company 'nobody'" in capsys.readouterr().err
|
assert "no company 'nobody'" in capsys.readouterr().err
|
||||||
|
|
||||||
assert _cli(tmp_path, "checked", "acme") == 0
|
assert _cli(tmp_path, "checked", "acme") == 0
|
||||||
stamp = json.loads(capsys.readouterr().out)["checked_at"]
|
stamp = json.loads(capsys.readouterr().out)["careers_opened_at"]
|
||||||
assert stamp and store.company("acme").checked_at == stamp # type: ignore[union-attr]
|
assert stamp and store.company("acme").careers_opened_at == stamp # type: ignore[union-attr]
|
||||||
assert _cli(tmp_path, "checked", "nobody") == 1
|
assert _cli(tmp_path, "checked", "nobody") == 1
|
||||||
capsys.readouterr()
|
capsys.readouterr()
|
||||||
|
|
||||||
@@ -499,20 +499,24 @@ def test_cli_edit_checked_and_remove_a_company_by_hand(
|
|||||||
assert _cli(tmp_path, "remove", "acme") == 1
|
assert _cli(tmp_path, "remove", "acme") == 1
|
||||||
|
|
||||||
|
|
||||||
def test_cli_by_hand_prints_never_checked_first_then_the_oldest_check(
|
def test_cli_by_hand_prints_never_opened_first_then_the_oldest_and_the_watch_rating(
|
||||||
store: Store, boards: Boards, tmp_path: Path,
|
store: Store, boards: Boards, tmp_path: Path,
|
||||||
capsys: pytest.CaptureFixture[str]) -> None:
|
capsys: pytest.CaptureFixture[str]) -> None:
|
||||||
store.add_company("Recent", careers_url="https://recent.example/jobs",
|
store.add_company("Recent", careers_url="https://recent.example/jobs",
|
||||||
hand_reason="gone", checked_at="2026-09-20T08:00:00+00:00")
|
hand_reason="gone")
|
||||||
store.add_company("Old", hand_reason="robots", checked_at="2026-08-01T08:00:00+00:00")
|
store.add_company("Old", hand_reason="robots")
|
||||||
store.add_company("Never", careers_url="https://never.example/jobs", hand_reason="added")
|
store.add_company("Never", careers_url="https://never.example/jobs", hand_reason="added")
|
||||||
|
store.update_company("recent", careers_opened_at="2026-09-20T08:00:00+00:00", watch=0)
|
||||||
|
store.update_company("old", careers_opened_at="2026-08-01T08:00:00+00:00", watch=1)
|
||||||
sources.set_board(store, "read", "greenhouse:acme", name="Read")
|
sources.set_board(store, "read", "greenhouse:acme", name="Read")
|
||||||
|
|
||||||
assert _cli(tmp_path, "by-hand") == 0
|
assert _cli(tmp_path, "by-hand") == 0
|
||||||
lines = capsys.readouterr().out.splitlines()
|
lines = capsys.readouterr().out.splitlines()
|
||||||
assert [ln.split()[0] for ln in lines[:-1]] == ["Never", "Old", "Recent"]
|
assert [ln.split()[0] for ln in lines[:-1]] == ["Never", "Old", "Recent"]
|
||||||
assert lines[0].split() == ["Never", "added", "never", "https://never.example/jobs"]
|
assert lines[0].split() == ["Never", "added", "-", "never", "https://never.example/jobs"]
|
||||||
assert lines[1].split() == ["Old", "robots", "2026-08-01"]
|
assert lines[1].split() == ["Old", "robots", "yes", "2026-08-01"]
|
||||||
|
assert lines[2].split() == ["Recent", "gone", "no", "2026-09-20",
|
||||||
|
"https://recent.example/jobs"]
|
||||||
assert lines[-1] == "3 by hand"
|
assert lines[-1] == "3 by hand"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user