oliver-zehentleitner / maity
clean-up: hub-wide: use events.newest_seq instead of five private copies
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-68newest_seq, a public twin (callerroutes/joins.py:1133)isolation.py:173-178_head(callers:150,:199)notifications/listing.py:276-281, inline per membership withcoalesce(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_seqat 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(aroundisolation.py:199), and tsk-sjq1h8tf6nmy editsgroup_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
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 helperjoins.py:1133already callshandover.newest_seq, so that call moves too when the helper moves