MCPcopy Index your code
hub / github.com/rilldata/rill / FindProjectsForOrgAndUser

Method FindProjectsForOrgAndUser

admin/database/postgres/postgres.go:353–373  ·  view source on GitHub ↗
(ctx context.Context, orgID, userID string, includePublic, includeGroups bool, afterProjectName string, limit int)

Source from the content-addressed store, hash-verified

351}
352
353func (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
375func (c *connection) FindPublicProjectsInOrganization(ctx context.Context, orgID, afterProjectName string, limit int) ([]*database.Project, error) {
376 var res []*projectDTO

Callers

nothing calls this directly

Calls 5

getDBMethod · 0.95
projectsFromDTOsMethod · 0.95
parseErrFunction · 0.85
SelectContextMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected