Skip to content

Padawan#78

Merged
PlebeianTech merged 109 commits into
mainfrom
padawan
Mar 6, 2026
Merged

Padawan#78
PlebeianTech merged 109 commits into
mainfrom
padawan

Conversation

@PlebeianTech

Copy link
Copy Markdown
Contributor

No description provided.

dcordz and others added 30 commits November 5, 2025 20:03
Replaced all usages of chart.js and react-chartjs-2 with @mui/x-charts.
Updated:
- DistrictVotesChart (BarChart)
- TotalVotesChart (BarChart)
- VoterDistrictAgreementChart (BarChart)
- VoterAgreementChart (BarChart)
- AffinityChart (PieChart, ScatterChart)

Updated vite.config.build.ts to remove chart.js chunks and include @mui/x-charts.
Cleaned up sway_utils/charts.ts.
Removed the @github/webauthn-json dependency and replaced its usage with
custom utility functions in app/frontend/sway_utils/webauthn.ts.

These utilities handle the conversion between Base64URL strings (used by
the server) and ArrayBuffers (required by the native WebAuthn API).

Key changes:
- Created app/frontend/sway_utils/webauthn.ts with `create` and `get`
  wrappers and Base64URL helpers.
- Updated authentication and registration hooks to use the new utilities.
- Removed @github/webauthn-json from package.json and vite.config.build.ts.
The user_legislators_by_locale method was causing an N+1 query by iterating over user_legislators and accessing nested associations inside the loop.

This change refactors the query to use 'joins' and 'where' to filter in the database and 'includes' to eager-load the associations, resolving the performance issue.

Co-authored-by: dcordz <17937472+dcordz@users.noreply.github.com>
This commit adds a set of Python scripts in the `legislation/` directory to:
1. Fetch and convert the Baltimore City Charter and Code from XML to Markdown (`fetch_law.py`).
2. Fetch recent Ordinances (2025-2026) from the Legistar API, download their PDF attachments, extract text, and generate a summary (`fetch_bills.py`).
3. Orchestrate the entire process (`main.py`).

The output is stored in `legislation/baltimore_city_charter.md`, `legislation/baltimore_city_code.md`, and `legislation/diffs/`. The `diffs/` directory is gitignored.

Co-authored-by: dcordz <17937472+dcordz@users.noreply.github.com>
…r-legislators-3571730287527064582

Fix N+1 query in user_legislators_by_locale
Co-authored-by: dcordz <17937472+dcordz@users.noreply.github.com>
Removed the @github/webauthn-json dependency and replaced its usage with
custom utility functions in app/frontend/sway_utils/webauthn.ts.

These utilities handle the conversion between Base64URL strings (used by
the server) and ArrayBuffers (required by the native WebAuthn API).

Key changes:
- Created app/frontend/sway_utils/webauthn.ts with `create` and `get`
  wrappers and Base64URL helpers (now correctly handling unpadded strings).
- Updated authentication and registration hooks to use the new utilities.
- Removed @github/webauthn-json from package.json and vite.config.build.ts.

Co-authored-by: dcordz <17937472+dcordz@users.noreply.github.com>
Updated VoterDistrictAgreementChart and VoterAgreementChart to use `swayFont` for titles instead of hardcoded "sans-serif".
Verified build passes.

Co-authored-by: dcordz <17937472+dcordz@users.noreply.github.com>
- Changed CONGRESS constant from 118 to 119 in lib/census.rb
- Updated test data in spec/support/files/congress.json to use CD119 instead of CD118
- Skipped pre-commit and tests as per user request and due to lack of Ruby environment

Co-authored-by: dcordz <17937472+dcordz@users.noreply.github.com>
This commit adds a set of Python scripts in the `legislation/` directory to:
1. Fetch and convert the Baltimore City Charter and Code from XML to Markdown (`fetch_law.py`).
2. Fetch recent Ordinances (2025-2026) from the Legistar API, download their PDF attachments, extract text, and generate a summary (`fetch_bills.py`).
3. Orchestrate the entire process (`main.py`).

The output is stored in `legislation/baltimore_city_charter.md`, `legislation/baltimore_city_code.md`, and `legislation/diffs/`. The `diffs/` directory is gitignored.

Co-authored-by: dcordz <17937472+dcordz@users.noreply.github.com>
…Calendar logic

Co-authored-by: dcordz <17937472+dcordz@users.noreply.github.com>
…9-2897759042693090323

Update Congress configuration to 119th Congress
Co-authored-by: dcordz <17937472+dcordz@users.noreply.github.com>
Removed the @github/webauthn-json dependency and replaced its usage with
custom utility functions in app/frontend/sway_utils/webauthn.ts.

These utilities handle the conversion between Base64URL strings (used by
the server) and ArrayBuffers (required by the native WebAuthn API).

Key changes:
- Created app/frontend/sway_utils/webauthn.ts with `create` and `get`
  wrappers using `PublicKeyCredential.parseCreationOptionsFromJSON` and
  `credential.toJSON()`.
- Updated authentication and registration hooks to use the new utilities.
- Removed @github/webauthn-json from package.json and vite.config.build.ts.
- Added explicit type compatibility definitions for legacy code.

Co-authored-by: dcordz <17937472+dcordz@users.noreply.github.com>
Replace Ruby-based block counting with database-level SQL counting.

- In `count_invites_where_inviter_is_user`, replaced `Invite.count { ... }` with `Invite.where(inviter_id: @user.id).count`.
- In `count_user_votes_by_locale`, replaced `UserVote.count { ... }` with `UserVote.joins(:bill).where(user_id: @user.id, bills: { sway_locale_id: @sway_locale.id }).count`.

These changes move filtering from Ruby memory to the database layer, significantly reducing memory usage and preventing N+1 queries when accessing the associated bill's locale ID.

Co-authored-by: dcordz <17937472+dcordz@users.noreply.github.com>
google-labs-jules Bot and others added 29 commits February 26, 2026 17:49
The `create` method already implements the functionality described by the TODO ("Create a position on a bill").
Existing tests in `spec/requests/organizations/positions_spec.rb` verify this behavior, confirming the TODO is obsolete.

Co-authored-by: dcordz <17937472+dcordz@users.noreply.github.com>
Added `.includes(:organization_bill_positions)` to `Organization.where(...)` queries in `BillsController#new` and `BillsController#edit` to prevent N+1 queries when serializing organization data.

Verified logic with a standalone reproduction script (since deleted) simulating ActiveRecord behavior, which confirmed the reduction in queries from O(N) to O(1) (technically 2 queries).

Co-authored-by: dcordz <17937472+dcordz@users.noreply.github.com>
- Added `.includes(:votes)` to `Bill.current_session` calls in `new` and `edit` actions of `BillsController`.
- This prevents N+1 queries when `to_sway_json` is called on each bill, which accesses the `vote` association.
- Verified with a reproduction script simulating the N+1 behavior and the fix.

Co-authored-by: dcordz <17937472+dcordz@users.noreply.github.com>
- Lift isSelected calculation to parent
- Wrap BillArgumentsOrganization in React.memo
- Pass stable props to children

Co-authored-by: dcordz <17937472+dcordz@users.noreply.github.com>
This commit adds a set of Python scripts in the `legislation/` directory to:
1. Fetch and convert the Baltimore City Charter and Code from XML to Markdown (`fetch_law.py`).
2. Fetch recent Ordinances (2025-2026) from the Legistar API, download their PDF attachments, extract text, and generate a summary (`fetch_bills.py`).
3. Orchestrate the entire process (`main.py`).

The scripts are designed to be run manually. Generated artifacts (markdown copies of the Charter/Code and Bill diffs/summaries) are gitignored to avoid bloating the repository.

Run `python3 legislation/main.py` to populate the data.

Co-authored-by: dcordz <17937472+dcordz@users.noreply.github.com>
- Add nested includes to eager load associations accessed in to_sway_json
- Use joins(:user_legislator) for correct user filtering

Co-authored-by: dcordz <17937472+dcordz@users.noreply.github.com>
…scores-n-plus-one-12849247401939525554

⚡ Optimize UserLegislatorScoresController index query
…9718051008337089617

Add legislation pipeline scripts
…itions-controller-5260384556739245592

Remove stale TODO in Organizations::PositionsController
…us-one-fix-16177993929539515317

⚡ Optimize BillsController index with eager loading
…-5114983175129052515

⚡ Resolve N+1 query in BillsController organizations fetch
…-n-plus-one-13373726571970258235

⚡ Optimize BillsController N+1 query on votes
…guments-rendering-16479765246779760606

⚡ Optimize BillArguments re-renders
@PlebeianTech PlebeianTech merged commit 900be07 into main Mar 6, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants