feat: show organization name for groups on user profile (#14448)

This commit is contained in:
Kayla Washburn-Love
2024-08-29 10:55:00 -06:00
committed by GitHub
parent 4b5c45d6df
commit 49afab12d5
29 changed files with 357 additions and 229 deletions

View File

@ -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