Skip to content

⚡ Bolt: Optimize articles API payload - #7

Merged
mkk2026 merged 1 commit into
masterfrom
bolt-optimize-articles-select-13850386038228845065
Feb 3, 2026
Merged

⚡ Bolt: Optimize articles API payload#7
mkk2026 merged 1 commit into
masterfrom
bolt-optimize-articles-select-13850386038228845065

Conversation

@mkk2026

@mkk2026 mkk2026 commented Feb 2, 2026

Copy link
Copy Markdown
Owner

Bolt Optimization

What:
Modified the GET /api/articles endpoint to use Prisma's select instead of include.

Why:
The previous implementation fetched all fields of SecurityArticle (including the potentially large content field) and all fields of Cve. The frontend list view does not display the article content or the CVE description, making this data transfer wasteful.

Impact:

  • Reduces the JSON payload size significantly for each request.
  • Reduces database I/O and memory usage by not retrieving large text blocks.
  • Faster response times for the articles list.

Verification:

  • Verified that all fields used by the frontend (id, url, title, summary, etc.) are still returned.
  • Verified that content and contentHash are no longer returned.
  • Verified using a custom script against the SQLite database.
  • Lint checks passed.

PR created automatically by Jules for task 13850386038228845065 started by @corebrimtech

Summary by CodeRabbit

  • Performance

    • Optimized articles API responses to return only essential fields, reducing payload size and improving data transfer efficiency.
  • Documentation

    • Added best practices guidance for efficient data retrieval patterns.

- Replaces `include` with explicit `select` in `GET /api/articles`
- Excludes large `content` and `contentHash` fields from `SecurityArticle`
- Excludes unused `description` field from `Cve`
- Reduces payload size and database I/O for the articles list view

This change improves performance by avoiding over-fetching of large text fields that are not displayed in the frontend list.

Co-authored-by: mkk2026 <175357468+mkk2026@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.

@coderabbitai

coderabbitai Bot commented Feb 2, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR adds documentation on Prisma query optimization for over-fetching and implements explicit field-level selection in the articles API endpoint. The articles endpoint now uses defined select projections instead of relation-based inclusion to return only necessary fields, reducing payload size.

Changes

Cohort / File(s) Summary
Documentation
.jules/bolt.md
Added subsection documenting Prisma over-fetching issue and recommending explicit field selection, particularly for avoiding Large Object (LOB) columns.
API Optimization
src/app/api/articles/route.ts
Replaced relation-based cves inclusion with explicit select on article fields (id, url, title, summary, source, sourceName, publishedAt, scrapedAt, severityScore, severityLevel) and nested cves fields (id, cveId, cvssScore, severity, affectedSoftware) to reduce payload size.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A rabbit hops through fields of data wide,
Selecting only treasures, casting bloat aside,
No over-fetched objects cluttering the way,
Just the essentials shipped—hooray, hooray! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main optimization change: replacing Prisma include with select to reduce API payload size, which is the primary focus of the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bolt-optimize-articles-select-13850386038228845065

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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