(ctx context.Context, req *adminv1.ListProjectsForUserByNameRequest)
| 231 | } |
| 232 | |
| 233 | func (s *Server) ListProjectsForUserByName(ctx context.Context, req *adminv1.ListProjectsForUserByNameRequest) (*adminv1.ListProjectsForUserByNameResponse, error) { |
| 234 | observability.AddRequestAttributes(ctx, |
| 235 | attribute.String("args.project", req.Name), |
| 236 | ) |
| 237 | |
| 238 | claims := auth.GetClaims(ctx) |
| 239 | userID := claims.OwnerID() |
| 240 | |
| 241 | projects, err := s.admin.DB.FindProjectsByNameAndUser(ctx, req.Name, userID) |
| 242 | if err != nil { |
| 243 | return nil, err |
| 244 | } |
| 245 | |
| 246 | orgsByID := make(map[string]*database.Organization) |
| 247 | |
| 248 | dtos := make([]*adminv1.Project, len(projects)) |
| 249 | for i, p := range projects { |
| 250 | org, hasOrg := orgsByID[p.OrganizationID] |
| 251 | if !hasOrg { |
| 252 | org, err = s.admin.DB.FindOrganization(ctx, p.OrganizationID) |
| 253 | if err != nil { |
| 254 | return nil, err |
| 255 | } |
| 256 | orgsByID[p.OrganizationID] = org |
| 257 | } |
| 258 | |
| 259 | dtos[i] = s.projToDTO(p, org.Name) |
| 260 | } |
| 261 | |
| 262 | return &adminv1.ListProjectsForUserByNameResponse{ |
| 263 | Projects: dtos, |
| 264 | }, nil |
| 265 | } |
| 266 | |
| 267 | func (s *Server) GetProject(ctx context.Context, req *adminv1.GetProjectRequest) (*adminv1.GetProjectResponse, error) { |
| 268 | observability.AddRequestAttributes(ctx, |
nothing calls this directly
no test coverage detected