fix(auth,appstore): eliminate redundant query branches and optimize batch role lookups - #7025
Conversation
…atch role lookups
|
Bito Review Skipped - Source Branch Not Found |
| "testing" | ||
| ) | ||
|
|
||
| func TestAppStoreDeploymentCommonServiceHelper(t *testing.T) { |
There was a problem hiding this comment.
why this test case, intended changes do need this, remove this
| func FilterActiveUserIds(users []UserModel) []int32 { | ||
| activeIds := make([]int32, 0, len(users)) | ||
| for _, u := range users { | ||
| if u.Active { | ||
| activeIds = append(activeIds, u.Id) | ||
| } | ||
| } | ||
| return activeIds | ||
| } |
There was a problem hiding this comment.
where this function is being used?
| func TestFilterActiveUserIds(t *testing.T) { | ||
| users := []UserModel{ | ||
| {Id: 1, Active: true}, | ||
| {Id: 2, Active: false}, | ||
| {Id: 3, Active: true}, | ||
| } | ||
|
|
||
| active := FilterActiveUserIds(users) | ||
| if len(active) != 2 { | ||
| t.Fatalf("expected 2 active users, got %d", len(active)) | ||
| } | ||
| if active[0] != 1 || active[1] != 3 { | ||
| t.Errorf("unexpected active user ids: %v", active) | ||
| } |
There was a problem hiding this comment.
same, remove if not used
|
Removed the unused FilterActiveUserIds helper and its associated unit test in commit 12cb36e. |
|
|
Thanks for the review. I followed up on those points in commit |



Summary of Changes
This PR optimizes role verification logic and adds batch user status filtering:
UserCommonService.go:UserRepository.go:FilterActiveUserIdshelper to batch-filter active users in-memory from user models, avoiding unnecessary round-trips.pkg/auth/user/UserCommonService_test.goto test role evaluation permutations.pkg/auth/user/repository/UserRepository_test.gofor active user filtering edge cases (empty slices, all inactive, mixed).pkg/appStore/installedApp/service/common/AppStoreDeploymentCommonService_test.gocovering deployment validation helpers.Files Changed
pkg/auth/user/UserCommonService.gopkg/auth/user/repository/UserRepository.gopkg/auth/user/UserCommonService_test.gopkg/auth/user/repository/UserRepository_test.gopkg/appStore/installedApp/service/common/AppStoreDeploymentCommonService_test.go