fix(WEBAPP-117): find user by id adjustments#119
Conversation
Coverage reportThe coverage rate went from The branch rate is
Diff Coverage details (click to unfold)app/api/auth/reset-password/route.ts
|
|
This pull request refactors the user-related data fetching logic to separate concerns and enhance modularity. The most significant change is the introduction of new functions in Refactoring and Modularization of User Data Fetching (
|
There was a problem hiding this comment.
Pull Request Overview
This PR refactors user-fetching logic by splitting the record retrieval and listing aggregation into focused functions, and updates components to use the new combined findUserByIdWithListings API.
- Separated basic user fetch (
findUserById) from listing counts and active listings retrieval - Introduced
getUserListingsCounts,getUserActiveListings,attachPhotosToListings, andgetAllCategories - Updated UI components to call
findUserByIdWithListingsinstead of the oldfindUserById
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| lib/users/actions.ts | Split user lookup and listing queries, added helper functions |
| components/listings/user-listings.tsx | Swapped in findUserByIdWithListings for listing-aware user fetch |
| app/(dashboard)/user/[id]/page.tsx | Updated profile page to use the combined listing API |
Comments suppressed due to low confidence (1)
lib/users/actions.ts:238
- Consider adding unit tests for findUserByIdWithListings and its helper functions (getUserListingsCounts, getUserActiveListings, attachPhotosToListings) to ensure correct data fetching and transformation.
export async function findUserByIdWithListings(
There was a problem hiding this comment.
Pull Request Overview
This PR addresses WEBAPP-117 by adjusting how users are fetched by ID across the codebase and refactors related functions for improved consistency. Key changes include:
- Renaming and replacing the findUserById function with getUserById and findUserByIdWithListings.
- Updating test files, API routes, and dashboard pages to use the new function names.
- Refactoring listing-related queries in lib/users/actions.ts for clarity and performance improvements.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/setup.js | Updated user action mocks to use getUserById |
| tests/api/auth/reset-password.test.ts | Updated function imports and mocks from findUserById to getUserById |
| lib/users/actions.ts | Refactored user query functions and introduced listing counts functions |
| components/listings/user-listings.tsx | Updated the user listings function import to use findUserByIdWithListings |
| app/api/auth/reset-password/route.ts | Updated function imports from findUserById to getUserById |
| app/(dashboard)/user/edit/page.tsx | Replaced findUserById with getUserById for user profile fetching |
| app/(dashboard)/user/[id]/page.tsx | Replaced findUserById with findUserByIdWithListings for richer user data |
No description provided.