Roles as a feed, a read page, votes that move the rank, unstar

The Roles tab is news's feed row: the title opens /roles/{uid}, company,
place and age under it, the badges, a one-line excerpt (summary, else the
description's opening), and ▲ ● ▼ ★ on the right, under the text at 640px.
The company affinity control leaves the row. A passed role and a hidden
company's are dimmed and stay. The filter bar is one row: order, search and
a Filters <details> holding the rest, with a judged select and "Show hidden
companies". The list loads 60 and appends on an IntersectionObserver
sentinel; back from a read page restores the filters, rows and scroll.

GET /api/roles takes offset, defaults to 60 and answers {items, total}.
judged= is a WHERE on roles.vote. Under a ranking the served score and the
order are the stored score moved by the vote (x0.5 pass, x1.2 like, capped
at 1), so a vote shows at once without a rescore. POST and DELETE
/api/roles/{uid}/vote set and clear it; pressing the pressed stance clears.

★ saves; pressed again it calls DELETE /api/applications/{id}, which drops
the application while it is still saved and answers 409 after. save_role no
longer writes the placeholder next step.

The read page (role.html, role.js) is news's reader: a bar with back,
▲ ● ▼ ★ and ↗, the company with its affinity control, place, badges, salary,
summary, the text (fetched posting, else description) and the link out.
It offers Fetch the posting for a teaser and Summarise without a summary,
against the /text and /summarise routes B4 adds. The vote and star buttons
are judge.js, shared by the feed and the reader.

Applications: titles open the read page, the Next column is gone, a Saved
column instead, and the lede says what the page is for.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Fable 5.1 committed 2026-09-25 21:51:48 +02:00
1 parent 7d31cca394
commit 09c5dde113
13 files changed
+1216 -192

No files matched your search

+55
View File
@@ -205,6 +205,61 @@ def test_roles_hide_muted_excludes_before_the_limit(store: Store, clock: Clock)
assert {r.source_id for r in store.roles()} == {"a0", "a1", "a2", "other"}
def test_roles_page_by_offset_and_count_the_same_filter(
store: Store, clock: Clock) -> None:
for sid in ("1", "2", "3", "4"):
store.upsert_role(posting(sid, company="Acme" if sid != "4" else "Other"))
clock.tick()
assert [r.source_id for r in store.roles(limit=2, offset=1)] == ["3", "2"]
assert [r.source_id for r in store.roles(limit=2, offset=3)] == ["1"]
assert store.count_roles() == 4
assert store.count_roles(company="acme") == 3
store.add_company("Other", key="other", affinity=-1)
assert store.count_roles(hide_muted=True) == 3
def test_a_vote_is_stamped_cleared_and_filtered(store: Store, clock: Clock) -> None:
for sid in ("up", "down", "fine", "none"):
store.upsert_role(posting(sid))
uid = {r.source_id: r.uid for r in store.roles()}
role = store.set_vote(uid["up"], 1)
assert (role.vote, role.voted_at) == (1, clock().isoformat(timespec="seconds"))
store.set_vote(uid["down"], -1)
store.set_vote(uid["fine"], 0)
assert [r.source_id for r in store.roles(judged="liked")] == ["up"]
assert [r.source_id for r in store.roles(judged="passed")] == ["down"]
assert [r.source_id for r in store.roles(judged="unjudged")] == ["none"]
assert store.count_roles(judged="unjudged") == 1
with pytest.raises(ValueError, match="judged"):
store.roles(judged="maybe")
cleared = store.set_vote(uid["up"], None)
assert (cleared.vote, cleared.voted_at) == (None, None)
with pytest.raises(ValueError):
store.set_vote(uid["up"], 2)
with pytest.raises(ValueError):
store.set_vote(uid["up"], True)
with pytest.raises(KeyError):
store.set_vote("nope", 1)
def test_a_vote_moves_the_served_score_and_the_order(store: Store) -> None:
for sid in ("a", "b", "c"):
store.upsert_role(posting(sid))
uid = {r.source_id: r.uid for r in store.roles()}
agent = store.save_agent("A")
store.replace_scores(agent.id, [(uid["a"], 0.9, ""), (uid["b"], 0.5, ""),
(uid["c"], 0.4, "")])
store.set_vote(uid["a"], -1) # 0.45
store.set_vote(uid["c"], 1) # 0.48
ranked = [(r.source_id, round(r.score or 0, 3)) for r in store.roles(agent=agent.id)]
assert ranked == [("b", 0.5), ("c", 0.48), ("a", 0.45)]
assert store.scores(agent.id)[uid["a"]][0] == 0.9 # the stored score is kept
store.set_vote(uid["a"], 1)
assert store.roles(agent=agent.id, limit=1)[0].score == 1.0
def test_mark_closed_closes_what_the_board_no_longer_lists(store: Store) -> None:
sub = store.add_subscription("ats", "greenhouse:acme")
other = store.add_subscription("ats", "greenhouse:other")