Skip to content

Link motions to agenda items in ExtractVotesJob #76

@AndreRobitaille

Description

@AndreRobitaille

Problem

Motion has a belongs_to :agenda_item association, but ExtractVotesJob never populates agenda_item_id. All 182 motions currently have agenda_item_id: nil.

This means:

  • Cannot trace votes to topics — the chain Vote → Motion → AgendaItem → AgendaItemTopic → Topic is broken, so we can't show "history of votes on a particular topic"
  • Cannot show vote detail per agenda item — the meeting show page can't render a collapsible vote breakdown inline with specific agenda items from database records (the page redesign works around this with AI-generated summary text, but database-backed vote grids per item aren't possible)

What Works Today

  • Vote → Motion → Meeting — member votes per meeting ✓
  • Motion → Meeting → Committee — which committee ✓
  • Vote → Member — who voted how ✓

What Needs to Change

ExtractVotesJob (which calls Ai::OpenAiService#extract_votes) needs to:

  1. Include agenda item context in the extraction prompt — pass agenda item IDs and titles alongside the minutes text so the AI can match motions to items
  2. Return agenda_item_id in the structured response for each motion
  3. Populate Motion.agenda_item_id when creating/updating motion records

The AI already reads minutes text that contains motion descriptions adjacent to agenda item discussions. The matching should be straightforward for most motions. Some motions (like consent agenda batch approvals) may not map cleanly to a single item.

Enables

  • Topic vote history page/section: Show all votes related to a topic across meetings (via Topic → AgendaItemTopic → AgendaItem → Motion → Vote)
  • Member voting record by topic: Group a member's votes by topic
  • Inline vote breakdown on meeting page: Show collapsible member-by-member vote grid attached to specific agenda items (currently the meeting page redesign uses AI-generated summary text for this; database records would allow richer, interactive display)

Backfill

After fixing ExtractVotesJob, re-run for all meetings with minutes to populate agenda_item_id on existing motions. The job is idempotent (uses find_or_create_by).

Not in Scope

  • Meeting show page redesign (separate, in progress)
  • Member show page vote display improvements
  • New vote history UI components

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions