Skip to content

⚡ Bolt: optimize admin categories query#186

Open
bbaaxx wants to merge 1 commit into
devfrom
bolt-optimize-admin-categories-17330098947948746916
Open

⚡ Bolt: optimize admin categories query#186
bbaaxx wants to merge 1 commit into
devfrom
bolt-optimize-admin-categories-17330098947948746916

Conversation

@bbaaxx

@bbaaxx bbaaxx commented Jun 21, 2026

Copy link
Copy Markdown
Owner

💡 What: Optimized the admin categories list by replacing a redundant db.batch call and manual in-memory counting with a single SQL aggregation query using LEFT JOIN and GROUP BY. Additionally, fixed a schema mismatch in scripts/init-db.ts where the level column was missing from the moves table, causing home page crashes.

🎯 Why: The previous implementation fetched all categories and then all moves to merge them in the application layer, which is inefficient as the data grows. Offloading this to the database reduces network overhead and CPU usage. The schema fix ensures the local development environment correctly reflects the application's data requirements.

📊 Impact:

  • Reduces database round-trips from multiple queries to one.
  • Eliminates application-layer overhead for counting related records.
  • Fixes critical runtime error on the home page for new local database setups.

🧪 Measurement: Verified via Playwright screenshots (confirming 0 and non-zero counts display correctly), pnpm lint, pnpm test:unit, and pnpm test:e2e.


PR created automatically by Jules for task 17330098947948746916 started by @bbaaxx

- Refactor admin categories load function to use a single SQL query with LEFT JOIN and GROUP BY for counting moves.
- Fix missing 'level' column in scripts/init-db.ts to resolve home page crashes.
- Add .jules/bolt.md with performance and schema learnings.

Co-authored-by: bbaaxx <3812307+bbaaxx@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

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.

1 participant