unified-storage: Reduce calls to the user service (#102934)
* Create ListByIdOrUID in user service * create UnstructuredToLegacyFolderList * update GetFolders to use list parser * update GetDescendants to use list parser * update UnstructuredToLegacyFolder to also make a single call to the user service --------- Co-authored-by: Stephanie Hingtgen <stephanie.hingtgen@grafana.com>
This commit is contained in:
co-authored by
Stephanie Hingtgen
parent
7e3efb3df2
commit
51825cfffe
@@ -6,16 +6,22 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/user"
|
||||
)
|
||||
|
||||
type ListUsersByIdOrUidCall struct {
|
||||
Uids []string
|
||||
Ids []int64
|
||||
}
|
||||
|
||||
type FakeUserService struct {
|
||||
ExpectedUser *user.User
|
||||
ExpectedSignedInUser *user.SignedInUser
|
||||
ExpectedError error
|
||||
ExpectedSetUsingOrgError error
|
||||
ExpectedSearchUsers user.SearchUserQueryResult
|
||||
ExpectedListUsers user.ListUserResult
|
||||
ExpectedUserProfileDTO *user.UserProfileDTO
|
||||
ExpectedUserProfileDTOs []*user.UserProfileDTO
|
||||
ExpectedUsageStats map[string]any
|
||||
ExpectedUser *user.User
|
||||
ExpectedSignedInUser *user.SignedInUser
|
||||
ExpectedError error
|
||||
ExpectedSetUsingOrgError error
|
||||
ExpectedSearchUsers user.SearchUserQueryResult
|
||||
ExpectedListUsers user.ListUserResult
|
||||
ExpectedListUsersByIdOrUid []*user.User
|
||||
ExpectedUserProfileDTO *user.UserProfileDTO
|
||||
ExpectedUserProfileDTOs []*user.UserProfileDTO
|
||||
ExpectedUsageStats map[string]any
|
||||
|
||||
UpdateFn func(ctx context.Context, cmd *user.UpdateUserCommand) error
|
||||
GetSignedInUserFn func(ctx context.Context, query *user.GetSignedInUserQuery) (*user.SignedInUser, error)
|
||||
@@ -25,6 +31,8 @@ type FakeUserService struct {
|
||||
GetByEmailFn func(ctx context.Context, query *user.GetUserByEmailQuery) (*user.User, error)
|
||||
|
||||
counter int
|
||||
|
||||
ListUsersByIdOrUidCalls []ListUsersByIdOrUidCall
|
||||
}
|
||||
|
||||
func NewUserServiceFake() *FakeUserService {
|
||||
@@ -59,6 +67,11 @@ func (f *FakeUserService) GetByUID(ctx context.Context, query *user.GetUserByUID
|
||||
return f.ExpectedUser, f.ExpectedError
|
||||
}
|
||||
|
||||
func (f *FakeUserService) ListByIdOrUID(ctx context.Context, uids []string, ids []int64) ([]*user.User, error) {
|
||||
f.ListUsersByIdOrUidCalls = append(f.ListUsersByIdOrUidCalls, ListUsersByIdOrUidCall{Uids: uids, Ids: ids})
|
||||
return f.ExpectedListUsersByIdOrUid, f.ExpectedError
|
||||
}
|
||||
|
||||
func (f *FakeUserService) GetByLogin(ctx context.Context, query *user.GetUserByLoginQuery) (*user.User, error) {
|
||||
if f.GetByLoginFn != nil {
|
||||
return f.GetByLoginFn(ctx, query)
|
||||
|
||||
@@ -230,6 +230,35 @@ func (_m *MockService) GetByUID(_a0 context.Context, _a1 *user.GetUserByUIDQuery
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
func (_m *MockService) ListByIdOrUID(_a0 context.Context, _a1 []string, _a2 []int64) ([]*user.User, error) {
|
||||
ret := _m.Called(_a0, _a1, _a2)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ListByIdOrUID")
|
||||
}
|
||||
|
||||
var r0 []*user.User
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, []string, []int64) ([]*user.User, error)); ok {
|
||||
return rf(_a0, _a1, _a2)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, []string, []int64) []*user.User); ok {
|
||||
r0 = rf(_a0, _a1, _a2)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]*user.User)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, []string, []int64) error); ok {
|
||||
r1 = rf(_a0, _a1, _a2)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetProfile provides a mock function with given fields: _a0, _a1
|
||||
func (_m *MockService) GetProfile(_a0 context.Context, _a1 *user.GetUserProfileQuery) (*user.UserProfileDTO, error) {
|
||||
ret := _m.Called(_a0, _a1)
|
||||
|
||||
Reference in New Issue
Block a user