Fix/graphql filtered count and seed script#3
Fix/graphql filtered count and seed script#3lukesmmr wants to merge 3 commits intoaudit-package-updatefrom
Conversation
countDisasters() previously ignored all filters (type, status, dateFrom, dateTo) and always returned the total row count. The GraphQL disasters query now returns accurate total and totalPages for filtered results. Co-authored-by: Cursor <cursoragent@cursor.com>
Three new tests verify that total and totalPages reflect the applied filters (status, type, and combined pagination + filter) rather than the unfiltered row count. Co-authored-by: Cursor <cursoragent@cursor.com>
Single TypeScript script (npm run seed) that populates the API via the bulk insert endpoint. Covers 6 continents, 12 disaster types, dates spanning Jan 2025 – Feb 2026, and all three statuses. Co-authored-by: Cursor <cursoragent@cursor.com>
📝 WalkthroughWalkthroughAdded seeding infrastructure to populate the database with sample disaster data via a new npm script, enhanced the disasters GraphQL query to respect filters when calculating totals and pagination, and introduced comprehensive tests validating filtering and pagination behavior. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
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. Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
js-0s
left a comment
There was a problem hiding this comment.
Great Work!
the count implementation looks unsafe
| } | ||
| const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(' AND ')}` : ''; | ||
| const result = (await prisma.$queryRawUnsafe( | ||
| `SELECT COUNT(*) FROM disasters ${whereClause}`, |
There was a problem hiding this comment.
i think this filtering could easily be implemented using a native prisma where which would make it less 'RawUnsafe'. the where would also be used in the actual result-edge
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Documentation