oliver-zehentleitner / maity

clean-up: hub-wide: use events.newest_seq instead of five private copies

Sign in to report

tsk-50zhasvxh7nt Open

From the clean-up audit tsk-hgnbapyw7hnh (finding A6-2), read at 80647565. Line numbers are at that SHA; check them against current main first. Paths are under hub/src/maity_hub/.

What is wrong

"The project's newest event seq" has a public helper, events.py:255-262 newest_seq, which invitations.py:316, org_projects.py:82, routes/joins.py:1110 and routes/projects.py:926 already use. Five more places run the same select(max(event.seq)).where(project_id == ...) and return int(found or 0) themselves.

Sites

  • chat_gate.py:262-266 _highest_seq (caller :304)
  • group_chats.py:370-374 _highest_seq (callers :531, :574; group_chats already imports events)
  • handover.py:63-68 newest_seq, a public twin (caller routes/joins.py:1133)
  • isolation.py:173-178 _head (callers :150, :199)
  • notifications/listing.py:276-281, inline per membership with coalesce(max(seq), 0) (found while grepping; not in the audit)

Not copies, leave them: routes/events.py:242-246 (a scalar subquery inside a wider statement), handover.py:154 (an extra filter), conversation_list.py:93 and notifications/listing.py:137, :186 (grouped per project).

Proposal

  • Call events.newest_seq at every site and delete the four functions and the inline copy. Use a local import where a module-level one would make a cycle.

Effort and risk

  • Effort S. Risk low: the same query and the same 0 for an empty project.

Order

  • tsk-hzqerzwemvhz item 7 edits isolation.lift (around isolation.py:199), and tsk-sjq1h8tf6nmy edits group_chats.py; rebase rather than conflict.

Covered elsewhere

  • None. Searched: newest_seq, _highest_seq; tsk-sjq1h8tf6nmy only lists A6-2 as left for this card.

Effort sum: S (1 point).

Notes

  1. Maity Coder Claude 003 · Nov 13, 2026, 23:12 UTC

    More sites from the clean-up audit (tsk-hgnbapyw7hnh, uncovered-files pass at 9dfd4b65):

    • events.py:255-262: probably the one to keep as the shared helper
    • joins.py:1133 already calls handover.newest_seq, so that call moves too when the helper moves