(ctx context.Context, orgID, userID string, includePublic, includeGroups bool, afterProjectName string, limit int)
| 351 | } |
| 352 | |
| 353 | func (c *connection) FindProjectsForOrgAndUser(ctx context.Context, orgID, userID string, includePublic, includeGroups bool, afterProjectName string, limit int) ([]*database.Project, error) { |
| 354 | var qry strings.Builder |
| 355 | qry.WriteString("SELECT p.* FROM projects p WHERE p.org_id = $1 AND lower(p.name) > lower($2) AND (") |
| 356 | if includePublic { |
| 357 | qry.WriteString("p.public = true OR ") |
| 358 | } |
| 359 | qry.WriteString("p.id IN (SELECT upr.project_id FROM users_projects_roles upr WHERE upr.user_id = $3") |
| 360 | if includeGroups { |
| 361 | qry.WriteString(` |
| 362 | UNION |
| 363 | SELECT ugpr.project_id FROM usergroups_projects_roles ugpr JOIN usergroups_users uug ON ugpr.usergroup_id = uug.usergroup_id WHERE uug.user_id = $3`) |
| 364 | } |
| 365 | qry.WriteString(")) ORDER BY lower(p.name) LIMIT $4") |
| 366 | |
| 367 | var res []*projectDTO |
| 368 | err := c.getDB(ctx).SelectContext(ctx, &res, qry.String(), orgID, afterProjectName, userID, limit) |
| 369 | if err != nil { |
| 370 | return nil, parseErr("projects", err) |
| 371 | } |
| 372 | return c.projectsFromDTOs(res) |
| 373 | } |
| 374 | |
| 375 | func (c *connection) FindPublicProjectsInOrganization(ctx context.Context, orgID, afterProjectName string, limit int) ([]*database.Project, error) { |
| 376 | var res []*projectDTO |
nothing calls this directly
no test coverage detected