Skip to content

[PM-21031] GET members performance optimization #5905

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

Draft
wants to merge 57 commits into
base: main
Choose a base branch
from

Conversation

r-tome
Copy link
Contributor

@r-tome r-tome commented Jun 2, 2025

🎟️ Tracking

📔 Objective

📸 Screenshots

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

r-tome added 11 commits May 29, 2025 13:28
…UserUserDetailsQuery for optimized user detail retrieval
…mize user detail retrieval and enhance two-factor authentication and claimed status handling
…sersRecipe

- Implemented methods to create collections and groups for organizations.
- Added logic to associate users with randomly assigned groups and collections.
- Enhanced bulk insertion of user associations for improved performance.
- Introduced GetManyDetailsByOrganizationOptimized_Projection method in both EF and Dapper repositories.
- This method utilizes conditional loading for improved performance and functionality.
- Added XML documentation to clarify usage and performance benefits.
- Note: Dapper implementation throws a NotImplementedException as this optimization is specific to EF.
…ort query optimization

- Updated Get and GetvNext methods in OrganizationUsersController to include a queryOptimization parameter for improved performance.
- Modified OrganizationUserUserDetailsQuery to conditionally use optimized projection based on the new parameter.
- Adjusted interface IOrganizationUserUserDetailsQuery to reflect the changes in method signatures.
- Added performance tests to compare optimized and unoptimized query execution times, ensuring data consistency between both methods.
…ails

- Introduced GetManyDetailsByOrganizationOptimized_SingleCall method in both Dapper and EF repositories.
- This method utilizes a single database call with multiple result sets to enhance performance by reducing round trips to the database.
- Added XML documentation to clarify usage and performance benefits of the new method.
…ails

- Created OrganizationUserUserDetails_ReadByOrganizationIdOptimized stored procedure to fetch user details, group associations, and collection associations in a single call.
- Supports conditional retrieval based on parameters for improved performance and reduced database round trips.
…ails

- Implemented GetManyDetailsByOrganizationAsync_WithGroupsAndCollections test to validate the performance and correctness of the optimized retrieval method.
- The test benchmarks the original and optimized query execution times, ensuring data consistency and logging results for performance improvements.
- Added cleanup logic to remove test data after execution to maintain test integrity.
… user details retrieval

- Changed the stored procedure name from OrganizationUserUserDetails_ReadByOrganizationIdOptimized to OrganizationUserUserDetails_WithGroupsCollections_ReadByOrganizationId to better reflect its functionality.
- Updated the OrganizationUserRepository to call the renamed stored procedure, ensuring consistency in the method used for retrieving organization user details along with group and collection associations.
…formance

- Renamed and updated repository methods to use GetManyDetailsByOrganizationAsync_vNext for optimized retrieval of organization user details.
- Removed outdated optimized methods and updated XML documentation to reflect the new approach.
- Added a new stored procedure to support the optimized retrieval of user details, groups, and collections in a single call.
- Updated integration tests to validate the new method and ensure performance improvements.
Copy link
Contributor

github-actions bot commented Jun 2, 2025

Logo
Checkmarx One – Scan Summary & Detailsc4be0942-0e99-4922-973e-d9ca000b4a70

Great job, no security vulnerabilities found in this Pull Request

r-tome added 9 commits June 2, 2025 10:39
…optimization parameter

- Updated Get and GetvNext methods in OrganizationUsersController and OrganizationUserUserDetailsQuery to eliminate the queryOptimization parameter, simplifying method signatures.
- Adjusted related interface IOrganizationUserUserDetailsQuery to reflect the changes in method definitions.
- Ensured consistent usage of optimized retrieval methods across the codebase.
…consistency

- Renamed methods in IOrganizationUserRepository and their implementations to improve clarity, changing GetManyDetailsByOrganizationAsync_vNext to GetManyDetailsWithGroupsCollectionsByOrganizationAsync.
- Updated XML documentation to reflect the new method names and their optimized retrieval strategies.
… and clarity

- Updated repository methods to use GetManyDetailsByOrganizationAsync_vNext, enhancing performance by reducing database round trips.
- Renamed and implemented a new stored procedure, OrganizationUserUserDetails_ReadByOrganizationId_V2, to support optimized retrieval of user details, groups, and collections in a single call.
- Adjusted XML documentation to reflect the changes in method names and their optimized retrieval strategies.
- Introduced GetManyByOrganizationWithClaimedDomainsAsync_vNext method in IOrganizationUserRepository for improved performance.
- Created a new stored procedure, OrganizationUser_ReadByOrganizationIdWithClaimedDomains_V2, to support the optimized retrieval.
- Added a new query class, OrganizationUserReadByClaimedOrganizationDomainsQuery_vNext, to facilitate the new retrieval logic.
- Updated XML documentation to reflect the new method and its performance enhancements.
- Updated OrganizationUsersControllerPerformanceTests to include a mock feature service for toggling optimization.
- Adjusted test cases to benchmark both optimized and unoptimized retrieval methods, ensuring accurate performance comparisons.
- Improved test output for clarity on performance improvements and data consistency checks.
- Added benchmarks to compare the original and optimized retrieval methods for organization users.
- Implemented detailed assertions to verify data consistency between both methods.
- Logged performance improvements and results for better visibility in test outputs.
- Introduced conditional logic in GetOrganizationUsersClaimedStatusQuery to utilize an optimized retrieval method based on feature flag.
- Removed the obsolete OrganizationUserReadByClaimedOrganizationDomainsQuery_vNext class to streamline the codebase.
- Updated OrganizationUserRepository to simplify the GetManyByOrganizationWithClaimedDomainsAsync_vNext method, ensuring it calls the existing method without unnecessary complexity.
…zation user retrieval

- Created OrganizationUserUserDetails_ReadByOrganizationId_V2 to retrieve user details, groups, and collections based on organization ID.
- Introduced OrganizationUser_ReadByOrganizationIdWithClaimedDomains_V2 to fetch users with verified domain claims for a given organization ID.
- Enhanced query structure to improve performance and clarity in data retrieval.
…tion

# Conflicts:
#	src/Core/Constants.cs
#	test/Api.IntegrationTest/AdminConsole/Controllers/OrganizationUsersControllerPerformanceTests.cs
Copy link

codecov bot commented Jun 2, 2025

Codecov Report

Attention: Patch coverage is 0% with 12 lines in your changes missing coverage. Please review.

Project coverage is 12.11%. Comparing base (0d34e87) to head (7dff110).
Report is 1 commits behind head on ac/pm-21031/optimize-get-members-endpoint-performance.

Files with missing lines Patch % Lines
...anizationUsers/OrganizationUserUserDetailsQuery.cs 0.00% 12 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (0d34e87) and HEAD (7dff110). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (0d34e87) HEAD (7dff110)
2 1
Additional details and impacted files
@@                                    Coverage Diff                                     @@
##           ac/pm-21031/optimize-get-members-endpoint-performance    #5905       +/-   ##
==========================================================================================
- Coverage                                                  51.34%   12.11%   -39.23%     
==========================================================================================
  Files                                                       1702     1003      -699     
  Lines                                                      75718    44463    -31255     
  Branches                                                    6812     3513     -3299     
==========================================================================================
- Hits                                                       38877     5387    -33490     
- Misses                                                     35310    38973     +3663     
+ Partials                                                    1531      103     -1428     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

r-tome added 8 commits June 2, 2025 13:32
…feature service

- Updated OrganizationUsersControllerPerformanceTests to include a mock feature service that allows toggling of the MembersGetEndpointOptimization flag.
- Improved test setup to ensure accurate performance comparisons between optimized and unoptimized retrieval methods.
- Set client timeout to 5 minutes for better handling of long-running tests.
…ieval

- Simplified the retrieval logic in OrganizationUsersController by directly returning the results from the query methods, reducing unnecessary variable declarations.
- Enhanced code clarity and maintainability while preserving existing functionality for managing users and account recovery enrolled users.
…nd performance

- Updated the method to utilize the optimized GetManyDetailsByOrganizationAsync_vNext for retrieving organization user details, enhancing performance.
- Simplified the response structure by directly incorporating user permissions and two-factor authentication status into the result set.
- Improved code readability by using descriptive variable names and reducing unnecessary complexity in the response generation logic.
…Domains that uses CTE for better performance
…_V2 for retrieving user details, group associations, and collection associations by organization ID.
…zationWithClaimedDomainsAsync_vNext in IOrganizationUserRepository to enhance performance by reducing database round trips.
r-tome added 27 commits June 2, 2025 15:12
…c_vNext to validate behavior with verified and unverified domains.
…into ac/pm-21031/get-members-performance-optimization
…stom user types in OrganizationUserUserDetailsQuery.
…into ac/pm-21031/get-members-performance-optimization
This update introduces the creation of sample custom permissions for OrganizationUser types in the OrganizationWithUsersRecipe. It implements a user type distribution strategy to test optimization, assigning permissions only to Custom users while varying user types among Admin, User, and Owner. This change aims to enhance performance by ensuring that permissions are processed efficiently based on user type.
…rformance

# Conflicts:
#	src/Core/Constants.cs
…that uses UserEmailDomainView to fetch Email domains
…tored procedure to use UserEmailDomainView for email domain extraction, improving query efficiency and clarity.
…etManyDetailsByOrganizationAsync method, clarifying its purpose and performance optimizations. Added remarks for better understanding of its functionality.
…Domain_V2.sql to adhere to coding standards.
…into ac/pm-21031/get-members-performance-optimization
…ganization domains, collections, and groups with domain distribution and optimized user types.
…into ac/pm-21031/get-members-performance-optimization
…into ac/pm-21031/get-members-performance-optimization
@r-tome r-tome changed the base branch from main to ac/pm-21031/optimize-get-members-endpoint-performance July 11, 2025 11:32
Copy link

Base automatically changed from ac/pm-21031/optimize-get-members-endpoint-performance to main July 23, 2025 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant