-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix incorrect total user count display on members page #426
Fix incorrect total user count display on members page #426
Conversation
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 eslint
backend/src/intelligence/intelligence.controller.tsOops! Something went wrong! :( ESLint: 9.12.0 ESLint couldn't find an eslint.config.(js|mjs|cjs) file. From ESLint v9.0.0, the default configuration file is now eslint.config.js. https://eslint.org/docs/latest/use/configure/migration-guide If you still have problems after following the migration guide, please stop by WalkthroughThe changes in this pull request involve modifications across several files, focusing on correcting typographical errors and enhancing user data handling. Key updates include fixing the constant name Changes
Assessment against linked issues
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (3)
frontend/src/components/drawers/WorkspaceDrawer.tsx (1)
1-4
: Consolidate Material-UI icon importsConsider using the destructured import pattern for better maintainability and consistency:
-import KeyboardDoubleArrowLeftIcon from "@mui/icons-material/KeyboardDoubleArrowLeft"; -import KeyboardDoubleArrowRightIcon from "@mui/icons-material/KeyboardDoubleArrowRight"; -import PeopleIcon from "@mui/icons-material/People"; -import SpaceDashboardIcon from "@mui/icons-material/SpaceDashboard"; +import { + KeyboardDoubleArrowLeft as KeyboardDoubleArrowLeftIcon, + KeyboardDoubleArrowRight as KeyboardDoubleArrowRightIcon, + People as PeopleIcon, + SpaceDashboard as SpaceDashboardIcon +} from "@mui/icons-material";frontend/src/pages/workspace/member/Index.tsx (2)
73-73
: Consider documenting standard component sizes.The change from "sm" to an explicit size of 20 is good for consistency, but consider documenting these standard sizes in a shared constants file or design system documentation.
Line range hint
65-78
: Consider enhancing error handling for infinite scroll.While the infinite scroll implementation works correctly, consider adding error handling and user feedback for failed page loads. This would improve the user experience when network issues occur.
<InfiniteScroll pageStart={0} loadMore={() => fetchNextPage()} hasMore={hasNextPage} + threshold={100} loader={ <Box className="loader" key={0}> <CircularProgress size={20} /> </Box> } + error={ + <Box className="error" key={1}> + <Typography color="error">Failed to load more members. Click to retry.</Typography> + </Box> + } useWindow={false} style={{ width: "100%", }} >
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
frontend/src/components/drawers/WorkspaceDrawer.tsx
(4 hunks)frontend/src/constants/layout.ts
(1 hunks)frontend/src/pages/workspace/member/Index.tsx
(3 hunks)
✅ Files skipped from review due to trivial changes (1)
- frontend/src/constants/layout.ts
🔇 Additional comments (3)
frontend/src/components/drawers/WorkspaceDrawer.tsx (1)
17-17
: Verify the constant rename impact across the codebase
The constant has been renamed from COLLAPESED_DRAWER_WIDTH
to COLLAPSED_DRAWER_WIDTH
. Let's ensure all references are updated.
Also applies to: 67-67, 80-80
✅ Verification successful
All references to the drawer width constant are using the correct spelling
The codebase search shows that all instances are using the new correct spelling COLLAPSED_DRAWER_WIDTH
. The constant is defined in frontend/src/constants/layout.ts
and consistently used in WorkspaceDrawer.tsx
with no occurrences of the old misspelled version COLLAPESED_DRAWER_WIDTH
.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for any remaining instances of the old constant name
rg "COLLAPESED_DRAWER_WIDTH"
# Search for all uses of the new constant name to verify consistency
rg "COLLAPSED_DRAWER_WIDTH"
Length of output: 482
frontend/src/pages/workspace/member/Index.tsx (2)
54-54
: LGTM! The user count now correctly displays the total number of users.
This change, combined with the useMemo implementation above, ensures that all workspace users are counted, fixing the previous limitation where only the first page was considered.
34-41
: LGTM! The useMemo implementation correctly aggregates all users.
The implementation properly flattens the paginated user list, addressing the core issue where only the first page of users was being counted. The null coalescing operator provides a safe fallback.
Let's verify that we're correctly processing all pages:
✅ Verification successful
The useMemo implementation correctly handles paginated user data
The implementation properly concatenates all pages of users, and the backend supports cursor-based pagination with a default page size of 10 users per request. The frontend's infinite query implementation correctly fetches and accumulates all pages, effectively removing the previous 10-user limitation. The dependency array is properly set to trigger recalculation when pages change.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for any hardcoded page size limits in the API hooks
# that might affect the total user count
rg -A 5 "useGetWorkspaceUserListQuery|getWorkspaceUserList"
Length of output: 1706
Script:
#!/bin/bash
# Let's check the API response type and pagination parameters
ast-grep --pattern 'type GetWorkspaceUserListResponse = {
$$$
}'
# Also check the API call implementation for any page size parameters
rg -A 10 '/workspaces/\$\{workspaceId\}/users'
Length of output: 752
Script:
#!/bin/bash
# Let's check the type definitions for pagination-related types
ast-grep --pattern 'interface $_ {
$$$
cursor?: $_
$$$
}'
# And check for any page size constants or configurations
rg -i "pagesize|page_size|limit" --type ts
Length of output: 3145
04a3fd4
to
7ea0bb5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
backend/src/workspace-users/workspace-users.service.ts (1)
58-68
: LGTM! Accurate implementation of total user count.The count query correctly uses the same filtering criteria as the main query, ensuring consistent results.
Consider caching the total count if it's frequently accessed and doesn't need to be real-time accurate, as this introduces an additional query for each request.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (12)
backend/src/intelligence/intelligence.controller.ts
(3 hunks)backend/src/users/users.controller.ts
(3 hunks)backend/src/utils/types/req.type.ts
(1 hunks)backend/src/workspace-documents/workspace-documents.controller.ts
(6 hunks)backend/src/workspace-users/types/find-workspace-users-response.type.ts
(1 hunks)backend/src/workspace-users/workspace-users.controller.ts
(2 hunks)backend/src/workspace-users/workspace-users.service.ts
(1 hunks)backend/src/workspaces/workspaces.controller.ts
(6 hunks)frontend/src/components/drawers/WorkspaceDrawer.tsx
(4 hunks)frontend/src/constants/layout.ts
(1 hunks)frontend/src/hooks/api/types/workspaceUser.d.ts
(1 hunks)frontend/src/pages/workspace/member/Index.tsx
(4 hunks)
✅ Files skipped from review due to trivial changes (3)
- backend/src/utils/types/req.type.ts
- backend/src/intelligence/intelligence.controller.ts
- backend/src/workspace-documents/workspace-documents.controller.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- frontend/src/constants/layout.ts
- frontend/src/components/drawers/WorkspaceDrawer.tsx
- frontend/src/pages/workspace/member/Index.tsx
🔇 Additional comments (7)
frontend/src/hooks/api/types/workspaceUser.d.ts (1)
6-6
: LGTM! Type definition aligns with backend response.The addition of
totalLength: number
toGetWorkspaceUserListResponse
correctly matches the backend response type and supports the fix for displaying total user count.backend/src/workspace-users/types/find-workspace-users-response.type.ts (1)
10-12
: LGTM! Well-documented API property addition.The
totalLength
property is properly typed and documented with clear API description, maintaining consistency with the frontend type definition.backend/src/users/users.controller.ts (1)
11-11
: Fixed typo in request type name.Corrected the spelling from
AuthroizedRequest
toAuthorizedRequest
across multiple method signatures and import statement.Also applies to: 27-27, 42-42
backend/src/workspace-users/workspace-users.service.ts (1)
73-73
: LGTM! Properly includes total count in response.The
totalLength
is correctly included in the response object.backend/src/workspace-users/workspace-users.controller.ts (2)
11-11
: LGTM! Fixed typo in import statement.Corrected the import from
AuthroizedRequest
toAuthorizedRequest
.
Line range hint
45-51
: Verify the integration with WorkspaceUsersService changes.The type correction from
AuthroizedRequest
toAuthorizedRequest
is good. However, since this PR aims to fix the total user count display, we should verify that the service layer changes are properly integrated.Let's verify the service implementation and response type:
✅ Verification successful
Total user count implementation is properly integrated ✅
The service layer changes are correctly integrated with:
- Prisma count query to get total users
- Response type including totalLength
- Service returning the count in response
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Check if WorkspaceUsersService.findMany returns totalLength ast-grep --pattern 'class WorkspaceUsersService { $$$ async findMany($$$) { $$$ return { $$$ totalLength $$$ } } }' # Check if FindWorkspaceUsersResponse includes totalLength ast-grep --pattern 'class FindWorkspaceUsersResponse { $$$ totalLength: number; $$$ }'Length of output: 248
Script:
#!/bin/bash # Find relevant files echo "=== Locating relevant files ===" rg -l "class WorkspaceUsersService" --type ts rg -l "FindWorkspaceUsersResponse" --type ts echo -e "\n=== Checking WorkspaceUsersService implementation ===" # Look for findMany method implementation rg "findMany.*\(" -A 10 --type ts echo -e "\n=== Checking response type definition ===" # Look for FindWorkspaceUsersResponse definition rg "FindWorkspaceUsersResponse" -A 5 --type tsLength of output: 17849
Script:
#!/bin/bash # Search for totalLength in workspace-users module echo "=== Searching for totalLength in workspace-users module ===" rg "totalLength" backend/src/workspace-users/ # Check for any modified files in workspace-users directory echo -e "\n=== Checking modified files in workspace-users directory ===" git diff --name-only HEAD backend/src/workspace-users/ # Look for count-related prisma queries in the service echo -e "\n=== Checking for count queries in service ===" rg "count|aggregate" backend/src/workspace-users/workspace-users.service.tsLength of output: 893
backend/src/workspaces/workspaces.controller.ts (1)
26-26
: LGTM! Consistent type correction across the controller.Fixed the typo from
AuthroizedRequest
toAuthorizedRequest
in the import statement and all method parameters. This change improves type safety while maintaining the same runtime behavior.Also applies to: 51-51, 68-68, 94-94, 118-118, 146-146
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM~
What this PR does / why we need it?
This PR fixes the issue where the total user count displayed on the members page is incorrectly set to a maximum of 10, regardless of the actual number of users present in the workspace. The updated code will ensure that the total user count accurately reflects the number of users in the workspace.
Any background context you want to provide?
The inconsistency in the user count display could lead to confusion for users, as they may think that the workspace has fewer participants than it actually does. This fix addresses that by removing the cap on the displayed count.
What are the relevant tickets?
Fixes #300
Checklist
Summary by CodeRabbit
New Features
totalLength
property to user response classes for better user count tracking.Bug Fixes
COLLAPESED_DRAWER_WIDTH
toCOLLAPSED_DRAWER_WIDTH
.AuthorizedRequest
across various components.Style