oliver-zehentleitner / maity
clean-up: G5 + hub: a member's membership looked up by hand beside access.member_row, and the ticker's one query per party
tsk-tvd8aq1s24ae Open
From the clean-up audit tsk-hgnbapyw7hnh (uncovered files, G5 Jour fixe, ticker, swarm, Keep the Why and memory), read at 9dfd4b65. Line numbers are at that SHA. Paths are under hub/src/maity_hub/.
1. Membership by member id: twelve copies beside access.member_row (duplication)
- The helpers:
access.member_row(access.py:150-163, active, raisesnot_found) andaccess.member_row_or_removed(:134-147). - Copies that select the row by
agent_id == x OR human_id == xthemselves: - in G5:
jourfixe/rounds.py:556-562(wake_now),jourfixe/triage.py:52-61(_membership_of, which ismember_row_or_removedwith another order andNoneinstead of 404),jourfixe/choices.py:25-33(_member_row),routes/jour_fixe.py:379-389(_member) and inline inend_moderator(:419-424); - for a human id only:
jourfixe/series.py:211-222(_is_member) andmemory.py:93-101(owner_membership); - outside G5:
bridges.py:226,public_cards.py:199,reports.py:168,routes/conversations.py:772,routes/projects.py:278. - What is wrong: each copy picks its own order and its own answer for "none" (
None,invalid,not_found), and the active/removed choice is easy to get wrong by hand. - Proposal:
access.find_member(conn, project_id, principal_id, *, removed=False) -> row | Nonebesidemember_row(which keeps raising), and every copy uses one of the two; each caller keeps its own error. - Effort: S-M (about a dozen small call sites). Risk: low.
2. The ticker resolves each party with its own query (slow path)
- Files:
ticker._principal_of(ticker.py:354-362), one select per call: four per decision item inon_request_answered(:383-387), and two per linked card inwrite_merge(:885-887, up to 20 cards, so up to 40 per merge). - Proposal: one
views.principal_ids(conn, [...])call per item (views.py:339, the batch form that exists). - Effort: S. Risk: none.
Covered elsewhere
- The
row.agent_id or row.human_idhelpers (rounds._principal,choices._principal,moderators._principal): tsk-es10trywfqs7 item 9. routes/tasks.audiencedoing the same per party: tsk-wfmyqaye48m7 item 7.- Agent-to-owner lookups: tsk-9tj3p6ca30m6. Handle lookups: tsk-ee3z4rakddq9.
- Searched: member_row, membership by principal, _member_of.
Effort sum: S-M + S, about 3 points.