Remove deadcode

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2026-03-13 16:50:35 +01:00
parent 7fd4221199
commit ef76a8d2e1
76 changed files with 137 additions and 4424 deletions

View File

@@ -183,169 +183,6 @@ WHERE
return nil
}
func (o *Organizations) LoadAllByIdentityID(
ctx context.Context,
conn pg.Conn,
identityID gid.GID,
) error {
q := `
WITH identity_org AS (
SELECT
organization_id
FROM
iam_memberships
WHERE
identity_id = @identity_id
)
SELECT
tenant_id,
id,
name,
description,
website_url,
email,
headquarter_address,
custom_domain_id,
logo_file_id,
horizontal_logo_file_id,
created_at,
updated_at
FROM
organizations
INNER JOIN
identity_org ON organizations.id = identity_org.organization_id
ORDER BY
name ASC
`
args := pgx.StrictNamedArgs{"identity_id": identityID}
rows, err := conn.Query(ctx, q, args)
if err != nil {
return fmt.Errorf("cannot query organizations: %w", err)
}
organizations, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[Organization])
if err != nil {
return fmt.Errorf("cannot collect organizations: %w", err)
}
*o = organizations
return nil
}
func (o *Organizations) LoadAllByIdentityIDWithRole(
ctx context.Context,
conn pg.Conn,
identityID gid.GID,
role MembershipRole,
) error {
q := `
WITH identity_org AS (
SELECT
organization_id
FROM
iam_memberships
WHERE
identity_id = @identity_id
AND role = @role
)
SELECT
tenant_id,
id,
name,
description,
website_url,
email,
headquarter_address,
custom_domain_id,
logo_file_id,
horizontal_logo_file_id,
created_at,
updated_at
FROM
organizations
INNER JOIN
identity_org ON organizations.id = identity_org.organization_id
ORDER BY
name ASC
`
args := pgx.StrictNamedArgs{
"identity_id": identityID,
"role": role,
}
rows, err := conn.Query(ctx, q, args)
if err != nil {
return fmt.Errorf("cannot query organizations: %w", err)
}
organizations, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[Organization])
if err != nil {
return fmt.Errorf("cannot collect organizations: %w", err)
}
*o = organizations
return nil
}
func (o *Organizations) LoadAllByPersonalAPIKeyID(
ctx context.Context,
conn pg.Conn,
personalAPIKeyID gid.GID,
) error {
q := `
WITH personal_api_key_org AS (
SELECT
am.organization_id
FROM
iam_personal_api_key_memberships akm
INNER JOIN
iam_memberships am ON akm.membership_id = am.id
WHERE
akm.personal_api_key_id = @personal_api_key_id
)
SELECT
tenant_id,
id,
name,
description,
website_url,
email,
headquarter_address,
custom_domain_id,
logo_file_id,
horizontal_logo_file_id,
created_at,
updated_at
FROM
organizations
INNER JOIN
personal_api_key_org ON organizations.id = personal_api_key_org.organization_id
ORDER BY
name ASC
`
args := pgx.StrictNamedArgs{"personal_api_key_id": personalAPIKeyID}
rows, err := conn.Query(ctx, q, args)
if err != nil {
return fmt.Errorf("cannot query organizations: %w", err)
}
organizations, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[Organization])
if err != nil {
return fmt.Errorf("cannot collect organizations: %w", err)
}
*o = organizations
return nil
}
func (o *Organization) Insert(
ctx context.Context,
conn pg.Conn,
@@ -509,49 +346,3 @@ LIMIT 1
return nil
}
func (o *Organizations) BatchLoadByID(
ctx context.Context,
conn pg.Conn,
scope Scoper,
organizationIDs []gid.GID,
) error {
q := `
SELECT
tenant_id,
id,
name,
logo_file_id,
horizontal_logo_file_id,
description,
website_url,
email,
headquarter_address,
custom_domain_id,
created_at,
updated_at
FROM
organizations
WHERE
%s
AND id = ANY(@organization_ids)
`
q = fmt.Sprintf(q, scope.SQLFragment())
args := pgx.StrictNamedArgs{"organization_ids": organizationIDs}
maps.Copy(args, scope.SQLArguments())
rows, err := conn.Query(ctx, q, args)
if err != nil {
return fmt.Errorf("cannot query organizations: %w", err)
}
organizations, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[Organization])
if err != nil {
return fmt.Errorf("cannot collect organizations: %w", err)
}
*o = organizations
return nil
}