Fixed some pointless drops list N+1 queries#2380
Conversation
Signed-off-by: GelatoGenesis <tarmokalling@gmail.com>
📝 WalkthroughWalkthroughProduction code adds optional ChangesV2 API Hydration Control and Test Coverage
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
__tests__/services/api/wave-drops-v2-api.test.ts (1)
397-419: ⚡ Quick winAdd an explicit
includeFullMetadata: falsedetail-path test.
fetchDropV2ByIdnow acceptsincludeFullMetadata, but this suite only verifies the default metadata-on behavior. A focused false-path assertion would lock in the N+1 optimization and prevent regressions.Proposed test addition
+ it("skips full metadata fetch for single drop details when includeFullMetadata is false", async () => { + commonApiFetchMock.mockResolvedValueOnce({ + wave, + drop: createEnrichableDrop(), + }); + + const result = await fetchDropV2ById("drop-1", undefined, { + includeFullMetadata: false, + includeTopRaters: false, + }); + + expect(commonApiFetchMock).toHaveBeenCalledTimes(1); + expect(commonApiFetchMock).not.toHaveBeenCalledWith( + expect.objectContaining({ + endpoint: expect.stringContaining("/metadata"), + }) + ); + expect(result.metadata).toEqual(priorityMetadata); + });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@__tests__/services/api/wave-drops-v2-api.test.ts` around lines 397 - 419, Add a focused test case for the false-path of includeFullMetadata: call fetchDropV2ById("drop-1", undefined, { includeFullMetadata: false, includeTopRaters: false }) and assert that commonApiFetchMock is NOT called with the "v2/drops/drop-1/metadata" endpoint (and only the primary "v2/drops/drop-1" call is made), and that the returned result.metadata equals only the priorityMetadata (not fullMetadata) and result.top_raters is [] to lock in the N+1 optimization; reference the existing test structure around fetchDropV2ById and expectations on commonApiFetchMock and result.metadata/top_raters to mirror assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@__tests__/services/api/wave-drops-v2-api.test.ts`:
- Around line 397-419: Add a focused test case for the false-path of
includeFullMetadata: call fetchDropV2ById("drop-1", undefined, {
includeFullMetadata: false, includeTopRaters: false }) and assert that
commonApiFetchMock is NOT called with the "v2/drops/drop-1/metadata" endpoint
(and only the primary "v2/drops/drop-1" call is made), and that the returned
result.metadata equals only the priorityMetadata (not fullMetadata) and
result.top_raters is [] to lock in the N+1 optimization; reference the existing
test structure around fetchDropV2ById and expectations on commonApiFetchMock and
result.metadata/top_raters to mirror assertions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 1a4c46d9-5acc-4a70-9710-adf3ac227604
📒 Files selected for processing (4)
__tests__/contexts/wave/utils/wave-messages-utils.additional.test.ts__tests__/contexts/wave/utils/wave-messages-utils.test.ts__tests__/services/api/wave-drops-v2-api.test.tsservices/api/wave-drops-v2-api.ts
|



Summary by CodeRabbit
Tests
Improvements