refactor(store): wave B.10 — user_group repo (#263)#264
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (7)
📝 WalkthroughWalkthroughAdds a store-layer UserGroupRepo (contracts + Postgres implementation), wires it into Repos, and migrates user-group read and membership queries across API handlers, SCIM, assignment validation, and search indexing to use the new repo methods. ChangesUser Group Repository Abstraction
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/store/postgres/user_group.go (1)
44-56: ⚡ Quick winConsolidate UserGroup mapping to reduce drift risk.
GetWithMembersduplicates the same basestore.UserGroupfield mapping used elsewhere. Extracting a shared mapper for common fields will prevent silent divergence when new fields are added.Also applies to: 120-132
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/store/postgres/user_group.go` around lines 44 - 56, GetWithMembers duplicates the base store.UserGroup field mapping, which risks divergence; extract a single reusable mapper (e.g., a function named mapUserGroupRow or newUserGroupFromRow) that accepts the DB row type and returns store.UserGroup, then call that mapper inside GetWithMembers and other places (also update the code at the other occurrence around lines 120-132) so shared fields like ID, Name, Description, MemberCount, CreatedAt, CreatedBy, UpdatedAt, IsDynamic, DynamicQuery, and MaintenanceWindow are populated in one place.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@internal/store/postgres/user_group.go`:
- Around line 44-56: GetWithMembers duplicates the base store.UserGroup field
mapping, which risks divergence; extract a single reusable mapper (e.g., a
function named mapUserGroupRow or newUserGroupFromRow) that accepts the DB row
type and returns store.UserGroup, then call that mapper inside GetWithMembers
and other places (also update the code at the other occurrence around lines
120-132) so shared fields like ID, Name, Description, MemberCount, CreatedAt,
CreatedBy, UpdatedAt, IsDynamic, DynamicQuery, and MaintenanceWindow are
populated in one place.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 81284143-3eca-4771-b5ea-53abb2cede0c
📒 Files selected for processing (9)
internal/api/assignment_handler.gointernal/api/user_group_handler.gointernal/scim/groups_helpers.gointernal/scim/groups_mutate.gointernal/search/index.gointernal/store/postgres/user_group.gointernal/store/postgres/wire.gointernal/store/repos.gointernal/store/user_group.go
UserGroupRepo covers the read side of user_groups_projection and user_group_members_projection: Get / GetByName / GetWithMembers / List / Count / ListForUser / ListMemberIDs / ListMembers UserGroupWithMembers pairs the projection row with the JOIN-computed ActualMemberCount so SCIM handlers can reconcile against projection lag. MaintenanceWindow stays as json.RawMessage at the boundary per the JSONB normalize plan in #242. Call sites migrated: - internal/api/user_group_handler.go — ~20 sites + userGroupToProto signature shifted to store.UserGroup - internal/scim/groups_helpers.go — 2 sites - internal/search/index.go — 1 site (group reindex sweep) Non-goals: - GetUserGroupRoles / UserGroupHasRole — Role-domain queries by group ID, will be added to RoleRepo in a follow-up wave. - EvaluateDynamicUserGroup / EvaluateQueuedDynamicUserGroups / ValidateUserGroupQuery — call PL/pgSQL, move with Wave C (dynamic-query interpreter port). - Write-side projector queries — stay on Queries() per pattern. Closes #263.
b355052 to
ad30608
Compare
Summary
`UserGroupRepo` — read side of `user_groups_projection` + `user_group_members_projection`. Branches off main directly.
Methods
`MaintenanceWindow` stays as `json.RawMessage` at the boundary per the JSONB normalize plan.
Call sites migrated
Non-goals
Acceptance
Part of #242. Closes #263.
Summary by CodeRabbit