mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
chore: merge organization member db queries (#13542)
Merge members queries into 1 that also joins in the user table for username. Required to list organization members on UI/cli
This commit is contained in:
@ -124,10 +124,10 @@ func ExtractOrganizationMemberParam(db database.Store) func(http.Handler) http.H
|
||||
}
|
||||
organization := OrganizationParam(r)
|
||||
|
||||
organizationMember, err := db.GetOrganizationMemberByUserID(ctx, database.GetOrganizationMemberByUserIDParams{
|
||||
organizationMember, err := database.ExpectOne(db.OrganizationMembers(ctx, database.OrganizationMembersParams{
|
||||
OrganizationID: organization.ID,
|
||||
UserID: user.ID,
|
||||
})
|
||||
}))
|
||||
if httpapi.Is404Error(err) {
|
||||
httpapi.ResourceNotFound(rw)
|
||||
return
|
||||
@ -141,7 +141,7 @@ func ExtractOrganizationMemberParam(db database.Store) func(http.Handler) http.H
|
||||
}
|
||||
|
||||
ctx = context.WithValue(ctx, organizationMemberParamContextKey{}, OrganizationMember{
|
||||
OrganizationMember: organizationMember,
|
||||
OrganizationMember: organizationMember.OrganizationMember,
|
||||
// Here we're making two exceptions to the rule about not leaking data about the user
|
||||
// to the API handler, which is to include the username and avatar URL.
|
||||
// If the caller has permission to read the OrganizationMember, then we're explicitly
|
||||
|
Reference in New Issue
Block a user