Skip to content

Commit 7f147fc

Browse files
committed
fix dbmem impl
1 parent 2b231a5 commit 7f147fc

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

coderd/database/dbmem/dbmem.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2609,6 +2609,10 @@ func (q *FakeQuerier) GetGroupMembersCountByGroupID(ctx context.Context, groupID
26092609
return int64(len(users)), nil
26102610
}
26112611

2612+
type GetGroupsCachedOrganizationDetails struct {
2613+
name, displayName string
2614+
}
2615+
26122616
func (q *FakeQuerier) GetGroups(_ context.Context, arg database.GetGroupsParams) ([]database.GetGroupsRow, error) {
26132617
err := validateDatabaseType(arg)
26142618
if err != nil {
@@ -2634,7 +2638,7 @@ func (q *FakeQuerier) GetGroups(_ context.Context, arg database.GetGroupsParams)
26342638
}
26352639
}
26362640

2637-
organizationDisplayNames := make(map[uuid.UUID]string)
2641+
organizationDisplayNames := make(map[uuid.UUID]struct{ name, displayName string })
26382642
filtered := make([]database.GetGroupsRow, 0)
26392643
for _, group := range q.groups {
26402644
if arg.OrganizationID != uuid.Nil && group.OrganizationID != arg.OrganizationID {
@@ -2646,20 +2650,23 @@ func (q *FakeQuerier) GetGroups(_ context.Context, arg database.GetGroupsParams)
26462650
continue
26472651
}
26482652

2649-
orgDisplayName, ok := organizationDisplayNames[group.ID]
2653+
orgDetails, ok := organizationDisplayNames[group.ID]
26502654
if !ok {
26512655
for _, org := range q.organizations {
26522656
if group.OrganizationID == org.ID {
2653-
orgDisplayName = org.DisplayName
2657+
orgDetails = struct{ name, displayName string }{
2658+
name: org.Name, displayName: org.DisplayName,
2659+
}
26542660
break
26552661
}
26562662
}
2657-
organizationDisplayNames[group.ID] = orgDisplayName
2663+
organizationDisplayNames[group.ID] = orgDetails
26582664
}
26592665

26602666
filtered = append(filtered, database.GetGroupsRow{
26612667
Group: group,
2662-
OrganizationDisplayName: orgDisplayName,
2668+
OrganizationName: orgDetails.name,
2669+
OrganizationDisplayName: orgDetails.displayName,
26632670
})
26642671
}
26652672

0 commit comments

Comments
 (0)