Skip to content

[PM-38270] perf: Speed up "claimed by organization" status checks on the Members page - #8125

Open
r-tome wants to merge 1 commit into
mainfrom
ac/pm-38270/speed-up-claimed-status-checks
Open

[PM-38270] perf: Speed up "claimed by organization" status checks on the Members page#8125
r-tome wants to merge 1 commit into
mainfrom
ac/pm-38270/speed-up-claimed-status-checks

Conversation

@r-tome

@r-tome r-tome commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-38270

📔 Objective

GetOrganizationUsersClaimedStatusQuery used .Any() inside a ToDictionary to test each user ID against the full claimed-users list — an O(n·m) scan that worsens as the Members page grows. This replaces it with a HashSet<Guid> built once before the loop, reducing complexity to O(n+m). Mirrors the same fix applied to TwoFactorIsEnabledQuery in PM-38265.

@r-tome r-tome added ai-review Request a Claude code review t:tech-debt Change Type - Tech debt labels Aug 3, 2026
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

🤖 Bitwarden Claude Code Review

Overall Assessment: APPROVE

Reviewed a single-file performance refactor in GetOrganizationUsersClaimedStatusQuery that hoists the claimed-user IDs into a HashSet<Guid> before the ToDictionary projection, replacing the per-user Any() scan and reducing lookup cost from O(n·m) to O(n+m). Behavior is preserved: claimedIds.Contains yields the same result as the prior ou.Id == ouId comparison because Guid uses value equality, and the disabled-organization and empty-input paths are unchanged. Existing unit tests in test/Core.Test/AdminConsole/OrganizationFeatures/OrganizationUsers/GetOrganizationUsersClaimedStatusQueryTests.cs already cover both the claimed and unclaimed outcomes and continue to exercise the refactored path. No security, correctness, breaking-change, or maintainability concerns identified.

Code Review Details

No findings at or above the reporting threshold.

@r-tome
r-tome marked this pull request as ready for review August 3, 2026 14:04
@r-tome
r-tome requested a review from a team as a code owner August 3, 2026 14:04
@r-tome
r-tome requested a review from sven-bitwarden August 3, 2026 14:04
@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.88%. Comparing base (3c01b90) to head (565734a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #8125       +/-   ##
===========================================
+ Coverage   15.18%   62.88%   +47.70%     
===========================================
  Files        1409     2304      +895     
  Lines       61106   100276    +39170     
  Branches     4865     9028     +4163     
===========================================
+ Hits         9277    63063    +53786     
+ Misses      51664    35029    -16635     
- Partials      165     2184     +2019     

☔ View full report in Codecov by Harness.
📢 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request a Claude code review t:tech-debt Change Type - Tech debt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants