mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
feat: show organization name for groups on user profile (#14448)
This commit is contained in:
committed by
GitHub
parent
4b5c45d6df
commit
49afab12d5
@ -2609,7 +2609,7 @@ func (q *FakeQuerier) GetGroupMembersCountByGroupID(ctx context.Context, groupID
|
||||
return int64(len(users)), nil
|
||||
}
|
||||
|
||||
func (q *FakeQuerier) GetGroups(_ context.Context, arg database.GetGroupsParams) ([]database.Group, error) {
|
||||
func (q *FakeQuerier) GetGroups(_ context.Context, arg database.GetGroupsParams) ([]database.GetGroupsRow, error) {
|
||||
err := validateDatabaseType(arg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -2634,7 +2634,8 @@ func (q *FakeQuerier) GetGroups(_ context.Context, arg database.GetGroupsParams)
|
||||
}
|
||||
}
|
||||
|
||||
filtered := make([]database.Group, 0)
|
||||
orgDetailsCache := make(map[uuid.UUID]struct{ name, displayName string })
|
||||
filtered := make([]database.GetGroupsRow, 0)
|
||||
for _, group := range q.groups {
|
||||
if arg.OrganizationID != uuid.Nil && group.OrganizationID != arg.OrganizationID {
|
||||
continue
|
||||
@ -2645,7 +2646,24 @@ func (q *FakeQuerier) GetGroups(_ context.Context, arg database.GetGroupsParams)
|
||||
continue
|
||||
}
|
||||
|
||||
filtered = append(filtered, group)
|
||||
orgDetails, ok := orgDetailsCache[group.ID]
|
||||
if !ok {
|
||||
for _, org := range q.organizations {
|
||||
if group.OrganizationID == org.ID {
|
||||
orgDetails = struct{ name, displayName string }{
|
||||
name: org.Name, displayName: org.DisplayName,
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
orgDetailsCache[group.ID] = orgDetails
|
||||
}
|
||||
|
||||
filtered = append(filtered, database.GetGroupsRow{
|
||||
Group: group,
|
||||
OrganizationName: orgDetails.name,
|
||||
OrganizationDisplayName: orgDetails.displayName,
|
||||
})
|
||||
}
|
||||
|
||||
return filtered, nil
|
||||
|
Reference in New Issue
Block a user