Repository navigation
Tested/Working Wishlist Population - #305
Conversation
✅ Deploy Preview for hope-for-haiti ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Greptile SummaryThis PR implements automatic wishlist population for unfulfilled partner requests. When a partner's request is not fully fulfilled — either because an admin sets a Key concerns:
Backend checklist areas needing improvement: operations are not fully optimized (sequential DB calls per iteration remain), edge cases around dual-trigger and Score: 62/100 Confidence Score: 3/5
Important Files Changed
|
|
@greptile-ai |
| } | ||
| } | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
Missing newline at end of file
Both wishlistService.ts and generalItemRequestService.ts now end without a trailing newline (the diff shows \ No newline at end of file). Most linters (e.g., ESLint's eol-last rule) treat this as a warning or error. Please restore the trailing newline to keep the linter happy and avoid noisy future diffs.
The same issue exists at the end of src/services/generalItemRequestService.ts.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| /** | ||
| * For each request where finalQuantity < quantity, automatically creates or | ||
| * updates a wishlist entry for the partner with the unfulfilled quantity. | ||
| * If an entry with the same name already exists for the partner, the | ||
| * unfulfilled quantity is added to it. | ||
| */ |
There was a problem hiding this comment.
JSDoc comment contradicts actual implementation
The doc says "the unfulfilled quantity is added to it", but line 83 does data: { quantity: unfulfilledQuantity } which replaces the existing quantity rather than incrementing it. The PR description also describes the additive behavior. The comment should be corrected to match the code's actual semantics:
* If an entry with the same name already exists for the partner, its
* quantity is replaced with the new unfulfilled quantity.915ea6b to
f07ac3c
Compare
✅ Deploy Preview for hope-for-haiti ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…manual quantity adjustments in table
…generalItemRequestService is sufficient
|
Added more robustness to you implementation so that manual entry changes also reflect in unfulfilled wishlist quantities. Otherwise, great work |
Description
Resolves ticket number: #296
Explain what your code changes:
When bulkUpdateRequests is called to set final quantities on partner requests, any request where finalQuantity < quantity now automatically creates a wishlist entry for that partner with the unfulfilled amount and the comment "Automatically generated due to unfulfilled request". The logic lives in a new createUnfulfilledWishlistEntries method in WishlistService, which is called after the bulk update transaction completes. If a partner already has a wishlist entry with the same item name, the unfulfilled quantity is added to it rather than creating a duplicate.
List the steps you took to test your code:
The seed file was updated with a three-partner test scenario mirroring the ticket exactly — 500 units of Cough Syrup, with Partner 1 (LOW, 200 requested, 0 fulfilled), Partner 2 (HIGH, 300 requested, 300 fulfilled), and Partner 3 (MEDIUM, 300 requested, 200 fulfilled). Console assertions confirmed wishlist entries were created only for Partners 1 and 3 with quantities 200 and 100 respectively, and Partner 2 had no entry. A second test case on a separate donor offer verified that a partner's existing wishlist entry for the same item name has its quantity merged rather than duplicated.
Checklist