Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Aug 29, 2024
Prev Previous commit
Next Next commit
fix dbmem impl
  • Loading branch information
aslilac committed Aug 27, 2024
commit 7f147fc25e3fd45ddc76d5631f3071c51800cdc5
17 changes: 12 additions & 5 deletions coderd/database/dbmem/dbmem.go
Original file line number Diff line number Diff line change
Expand Up @@ -2609,6 +2609,10 @@
return int64(len(users)), nil
}

type GetGroupsCachedOrganizationDetails struct {
name, displayName string

Check failure on line 2613 in coderd/database/dbmem/dbmem.go

View workflow job for this annotation

GitHub Actions / lint

field `name` is unused (unused)
}

func (q *FakeQuerier) GetGroups(_ context.Context, arg database.GetGroupsParams) ([]database.GetGroupsRow, error) {
err := validateDatabaseType(arg)
if err != nil {
Expand All @@ -2634,7 +2638,7 @@
}
}

organizationDisplayNames := make(map[uuid.UUID]string)
organizationDisplayNames := 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 {
Expand All @@ -2646,20 +2650,23 @@
continue
}

orgDisplayName, ok := organizationDisplayNames[group.ID]
orgDetails, ok := organizationDisplayNames[group.ID]
if !ok {
for _, org := range q.organizations {
if group.OrganizationID == org.ID {
orgDisplayName = org.DisplayName
orgDetails = struct{ name, displayName string }{
name: org.Name, displayName: org.DisplayName,
}
break
}
}
organizationDisplayNames[group.ID] = orgDisplayName
organizationDisplayNames[group.ID] = orgDetails
}

filtered = append(filtered, database.GetGroupsRow{
Group: group,
OrganizationDisplayName: orgDisplayName,
OrganizationName: orgDetails.name,
OrganizationDisplayName: orgDetails.displayName,
})
}

Expand Down
Loading