-
Notifications
You must be signed in to change notification settings - Fork 726
Org and member view updates (LFX-1664) #2660
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
Conversation
WalkthroughThe changes involve significant updates to various components related to member and organization saved views in both the backend and frontend. Key modifications include the removal of certain settings related to bot visibility and activity counts, adjustments to query handling in the Changes
Possibly related PRs
Suggested reviewers
Poem
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 (8)
frontend/src/modules/organization/config/saved-views/views/all-organizations.ts (2)
16-16: LGTM! Consider updating documentation.The change from 'exclude' to 'include' for
teamOrganizationaligns with the PR objective to remove default filters. This change effectively shows all organizations regardless of their team status.Consider updating the relevant API or component documentation to reflect this change in filtering behavior.
hasActivitiesfilter still present in main configurationThe
hasActivities: 'true'filter is still present infrontend/src/modules/organization/config/saved-views/main.ts, which contradicts the PR objective of showing all organizations. This remaining filter needs to be removed to fully implement the intended changes.
frontend/src/modules/organization/config/saved-views/main.ts: Remove thehasActivities: 'true'setting to allow displaying all organizations regardless of their activity status.🔗 Analysis chain
Line range hint
12-17: Verify the complete removal of activity-related filters.The removal of the
hasActivitiesproperty from settings aligns with the PR objective to show all organizations. However, let's verify that this property has been completely removed from the related configuration files.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Search for any remaining hasActivities configurations in organization-related files # Expected: No occurrences of hasActivities in organization view configurations echo "Checking for hasActivities in organization configurations..." rg -l "hasActivities" "frontend/src/modules/organization"Length of output: 247
Script:
#!/bin/bash # Check the content of main.ts to understand the hasActivities usage rg -A 5 -B 5 "hasActivities" "frontend/src/modules/organization/config/saved-views/main.ts"Length of output: 262
frontend/src/modules/member/config/saved-views/views/unaffiliated.ts (1)
Line range hint
1-23: Consider adding JSDoc comments to document the view's purpose.Adding documentation about the view's purpose and the significance of each setting would improve maintainability, especially given the recent changes to the filtering behavior.
import { SavedView } from '@/shared/modules/saved-views/types/SavedViewsConfig'; +/** + * Unaffiliated members view configuration + * Shows members without organization affiliations + * Note: Includes team members as of LFX-1664 + */ const unaffiliated: SavedView = {frontend/src/shared/modules/filters/config/defaultFilterRenderer/member.defaultFilter.renderer.ts (1)
5-16: LGTM: Clean and complete implementation.The function correctly handles all possible states of
teamMemberwith clear descriptive messages.Consider maintaining consistent spacing between the conditional blocks to improve readability. The current implementation has varying gaps between blocks.
services/libs/data-access-layer/src/members/base.ts (1)
238-238: LGTM! Consider index optimization for the LEFT JOIN.The change from INNER JOIN to LEFT JOIN correctly implements the requirement to include members without activities. This works well with the COALESCE defaults and NULLS LAST ordering.
Consider adding an index on
(memberId, segmentId)in the memberSegmentsAgg table if not already present, as this will improve the performance of the LEFT JOIN operation, especially as the dataset grows.services/libs/opensearch/src/service/member.sync.service.ts (2)
486-493: LGTM! Consider adding a comment for clarity.The explicit handling of falsy
syncResultsimproves error handling and aligns with the PR objectives to handle members without activities.Consider adding a comment to explain when
syncResultsmight be falsy:+ // Return syncResults if aggregates were processed, otherwise return default zero counts if (syncResults) { return syncResults }
484-493: Document the relationship between activity filtering and aggregate processing.The
syncMembersmethod's behavior depends on both thewithAggsoption and the presence of activities. Consider documenting these relationships:Add JSDoc comments to explain the method's behavior:
+ /** + * Syncs a member's data to OpenSearch and optionally processes their aggregates. + * @param memberId - The ID of the member to sync + * @param opts - Sync options + * @param opts.withAggs - When true, processes member aggregates before syncing. + * Members without activities will return zero counts. + * @returns IMemberSyncResult indicating the number of members synced and documents indexed + */ public async syncMembers( memberId: string, opts: { withAggs?: boolean } = { withAggs: true }, ): Promise<IMemberSyncResult> {backend/src/database/repositories/organizationRepository.ts (1)
Line range hint
1696-1722: Consider fixing the query string indentation.The query string's indentation appears to be inconsistent. Consider adjusting it for better readability:
- const query = ` - ${createQuery( - (function prepareFields(fields) { + const query = ` + ${createQuery( + (function prepareFields(fields) {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (13)
- backend/src/database/repositories/organizationRepository.ts (4 hunks)
- frontend/src/modules/member/config/saved-views/main.ts (0 hunks)
- frontend/src/modules/member/config/saved-views/settings/bot/MemberBotSetting.vue (0 hunks)
- frontend/src/modules/member/config/saved-views/settings/bot/config.ts (0 hunks)
- frontend/src/modules/member/config/saved-views/views/all-members.ts (1 hunks)
- frontend/src/modules/member/config/saved-views/views/to-review.ts (1 hunks)
- frontend/src/modules/member/config/saved-views/views/unaffiliated.ts (1 hunks)
- frontend/src/modules/organization/config/saved-views/main.ts (0 hunks)
- frontend/src/modules/organization/config/saved-views/settings/hasActivities/config.ts (0 hunks)
- frontend/src/modules/organization/config/saved-views/views/all-organizations.ts (1 hunks)
- frontend/src/shared/modules/filters/config/defaultFilterRenderer/member.defaultFilter.renderer.ts (1 hunks)
- services/libs/data-access-layer/src/members/base.ts (2 hunks)
- services/libs/opensearch/src/service/member.sync.service.ts (1 hunks)
💤 Files with no reviewable changes (5)
- frontend/src/modules/member/config/saved-views/main.ts
- frontend/src/modules/member/config/saved-views/settings/bot/MemberBotSetting.vue
- frontend/src/modules/member/config/saved-views/settings/bot/config.ts
- frontend/src/modules/organization/config/saved-views/main.ts
- frontend/src/modules/organization/config/saved-views/settings/hasActivities/config.ts
🔇 Additional comments (11)
frontend/src/modules/member/config/saved-views/views/all-members.ts (2)
16-16: LGTM! Change aligns with PR objectives.The update to include team members by default aligns with the PR objective to remove default filters.
13-18: Verify complete removal of bot settings.The bot setting has been removed from this config, which aligns with PR objectives. Let's verify this change is consistent across the codebase.
✅ Verification successful
Bot settings have been successfully removed from saved views configuration
The verification shows that while there are some legitimate bot-related properties in the member service and components (
isBotfield), there are no remaining bot settings in the saved views configuration files. This confirms the complete removal of bot settings from the configuration as intended.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Search for any remaining bot settings in saved views configs # Expected: No occurrences of bot settings in saved views echo "Checking for bot settings in saved views..." rg -g '*.ts' -g '*.vue' 'bot.*:.*["\'](?:include|exclude)["\']' frontend/src/modules/member/Length of output: 326
Script:
#!/bin/bash # Let's try a simpler pattern to search for bot settings echo "Searching for bot settings in saved views..." rg -i "bot.*:" frontend/src/modules/member/ # Also search for any references to bot in the config files echo -e "\nSearching for 'bot' in config files..." fd -e ts -e vue . frontend/src/modules/member/config --exec rg -i "bot"Length of output: 537
frontend/src/modules/member/config/saved-views/views/unaffiliated.ts (1)
16-16: Verify the impact of including team members in unaffiliated view.The change from excluding to including team members in the unaffiliated view might affect existing workflows. Please ensure this aligns with the expected behavior for unaffiliated members.
frontend/src/modules/member/config/saved-views/views/to-review.ts (2)
16-18: LGTM! Changes align with PR objectives.The modification to include team members and removal of the bot filter aligns with the PR objectives to show all members regardless of their status.
16-18: Verify consistency across other saved views.Let's ensure these changes are consistently applied across all saved view configurations.
✅ Verification successful
Based on the shell script results, I can now generate the final response since I have sufficient information about all saved view configurations.
Changes are consistently applied across all saved views ✓
All saved view configurations (
unaffiliated,to-review, andall-members) have consistent settings with:
teamMember: 'include'organization: 'exclude'🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for consistent settings across all saved view configurations # Expected: All saved views should have similar changes (bot filter removed, teamMember included) echo "Checking saved view configurations..." rg -l "SavedView" frontend/src/modules/member/config/saved-views/views/ | xargs cat # Also check the main saved views configuration echo "Checking main saved views configuration..." rg -A 10 "memberSavedViews" frontend/src/modules/member/config/saved-views/Length of output: 2663
frontend/src/shared/modules/filters/config/defaultFilterRenderer/member.defaultFilter.renderer.ts (1)
4-4: LGTM: Function signature simplified as intended.The removal of the
botparameter aligns with the PR objective to remove theisBotfilter from the frontend.services/libs/data-access-layer/src/members/base.ts (1)
85-91: LGTM! Verify the impact of default values.The addition of COALESCE for handling null values is well-implemented and aligns with the PR objectives. This ensures that members without activities are properly handled with sensible default values.
Let's verify the query behavior with these changes:
✅ Verification successful
Based on the search results and code analysis, I can now generate the final response:
The COALESCE handling for null values is correctly implemented and safe to use
The changes ensure proper handling of members without activities by:
- Setting default values through COALESCE (empty arrays for platforms/types, 0 for numeric fields)
- Respecting NULLS LAST in ORDER BY clause, which will place members without activities at the end when sorting
The verification shows:
- The query implementation includes
ORDER BY ${order} NULLS LASTwhich correctly handles null values in sorting- The COALESCE defaults align with PostgreSQL's type system (empty arrays for array fields, 0 for numeric fields)
- No conflicting usages of these fields were found in the codebase
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the query returns members without activities # and that they appear at the end of results when ordered by activity count # Search for test cases or example queries that verify this behavior rg -l 'queryMembersAdvanced.*orderBy.*activityCount' --type ts # Look for any existing tests that might need updates rg -l 'test.*members.*without.*activities' --type tsLength of output: 119
Script:
#!/bin/bash # Let's try a broader search to understand the query implementation and tests # Search for the query implementation ast-grep --pattern 'queryMembersAdvanced($$$) { $$$ }' # Look for test files related to members fd test.*members.*\.ts # Search for order by clauses in member queries rg -A 5 'ORDER BY.*activity' --type ts # Check for existing test cases with null handling rg -A 5 'coalesce.*msa' --type tsLength of output: 1367
Script:
#!/bin/bash # Let's examine the SQL join and order by clauses in the member queries # Search for LEFT JOIN with member_segment_activities rg -B 5 -A 5 'LEFT.*JOIN.*member_segment_activities' --type ts # Look for ORDER BY clauses in the base.ts file rg -B 5 -A 5 'ORDER BY' services/libs/data-access-layer/src/members/base.ts # Check for any SQL tests or fixtures fd -e sqlLength of output: 26792
services/libs/opensearch/src/service/member.sync.service.ts (1)
484-493: Verify handling of zero counts by callers.Let's verify that all callers of
syncMembersproperly handle the case when zero counts are returned.✅ Verification successful
Let me analyze the code further by checking the implementation details of the callers.
Let me check one more aspect about error handling with a corrected regex.
Based on the evidence gathered from the codebase:
Zero counts are safely handled across all callers
The implementation is safe because:
- The API route handler in
search_sync_apionly cares about completion status (returns 200) and properly handles errors- The sync service itself uses the counts in accumulator variables (
docCount += documentsIndexed) which safely handles zero values- Other callers in
search_sync_workerandmembers_enrichment_workerhave proper error handling and don't depend on specific count valuesThe zero count return value is a valid business case that's properly handled throughout the codebase.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Find all callers of syncMembers and verify their handling of zero counts # Find all references to syncMembers echo "Searching for syncMembers calls:" rg -A 5 "syncMembers\(" --type ts # Find any error handling around these calls echo -e "\nSearching for error handling around syncMembers:" rg -B 5 -A 5 "syncMembers\(.*\).*catch" --type tsLength of output: 4306
Script:
#!/bin/bash # Check implementation of callers to see how they handle the return values # First check the member sync service itself echo "Checking MemberSyncService implementation:" ast-grep --pattern 'const { membersSynced, documentsIndexed } = await this.syncMembers' # Check how docCount and memberCount are used echo -e "\nChecking usage of count variables:" rg -B 5 -A 5 "docCount \+= documentsIndexed" --type ts # Check error handling in the service echo -e "\nChecking error handling in sync service:" rg -B 10 -A 5 "catch.*{" services/libs/opensearch/src/service/member.sync.service.tsLength of output: 3702
Script:
#!/bin/bash # Check error handling in the service and its callers # Check error handling in the sync service with fixed regex echo "Checking error handling in sync service:" rg -B 10 -A 5 "catch \{" services/libs/opensearch/src/service/member.sync.service.ts # Check the implementation of syncMembers method echo -e "\nChecking syncMembers implementation:" ast-grep --pattern 'syncMembers($_, $_) { $$$ }' # Check how the return value is used in API routes echo -e "\nChecking API route handlers:" rg -B 5 -A 5 "memberSyncService.syncMembers" services/apps/search_sync_api/src/routes/Length of output: 1505
backend/src/database/repositories/organizationRepository.ts (3)
107-112: LGTM: Improved null handling for activity-related fields.The use of
coalesceensures consistent behavior when filtering and sorting organizations by providing default values (0 or empty array) for null fields. This change aligns with the PR objective to properly handle organizations without activities.
1685-1685: LGTM: Critical change to include organizations without activities.The modification from an implicit INNER JOIN to an explicit LEFT JOIN is crucial for the PR objectives. This change ensures that organizations without activities (no entries in organizationSegmentsAgg) are included in the query results.
Line range hint
1696-1719: LGTM: Improved query construction and null handling in ordering.The changes enhance query handling by:
- Properly filtering aggregated fields when not needed
- Adding NULLS LAST to ensure consistent ordering
- Improving code organization with separate count query
Changes proposed
Organizations view changes:
isTeamOrganizationandactivityCountdefault filters on frontendMembers view changes:
isTeamOrganizationandisBotdefault filters on frontendChecklist ✅
Feature,Improvement, orBug.Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Chores