Feat v0.9.4 package adoption roles (#78)
All checks were successful
CI/CD / detect-changes (push) Successful in 3s
CI/CD / test-frontend (push) Has been skipped
CI/CD / test-runners (push) Has been skipped
CI/CD / e2e-smoke (push) Has been skipped
CI/CD / test-go-pg (push) Successful in 2m55s
CI/CD / test-sqlite (push) Successful in 3m7s
CI/CD / build-and-deploy (push) Successful in 1m19s
All checks were successful
CI/CD / detect-changes (push) Successful in 3s
CI/CD / test-frontend (push) Has been skipped
CI/CD / test-runners (push) Has been skipped
CI/CD / e2e-smoke (push) Has been skipped
CI/CD / test-go-pg (push) Successful in 2m55s
CI/CD / test-sqlite (push) Successful in 3m7s
CI/CD / build-and-deploy (push) Successful in 1m19s
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com> Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit was merged in pull request #78.
This commit is contained in:
@@ -8,6 +8,8 @@ import (
|
||||
|
||||
"armature/models"
|
||||
"armature/store"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type TeamStore struct{}
|
||||
@@ -399,3 +401,40 @@ func (s *TeamStore) RemoveAllUserRoles(ctx context.Context, teamID, userID strin
|
||||
teamID, userID)
|
||||
return err
|
||||
}
|
||||
|
||||
// ── v0.9.4 — Team Role Catalog ──
|
||||
|
||||
func (s *TeamStore) AddRoleToCatalog(ctx context.Context, teamID, role, sourcePkgID string) error {
|
||||
_, err := DB.ExecContext(ctx, `
|
||||
INSERT INTO team_role_catalog (id, team_id, role, source_package_id)
|
||||
VALUES (?, ?, ?, ?)
|
||||
ON CONFLICT (team_id, role) DO NOTHING`,
|
||||
uuid.New().String(), teamID, role, sourcePkgID)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *TeamStore) ListRoleCatalog(ctx context.Context, teamID string) ([]store.TeamRoleCatalogEntry, error) {
|
||||
rows, err := DB.QueryContext(ctx, `
|
||||
SELECT role, COALESCE(source_package_id, '') FROM team_role_catalog
|
||||
WHERE team_id = ? ORDER BY role`, teamID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var result []store.TeamRoleCatalogEntry
|
||||
for rows.Next() {
|
||||
var e store.TeamRoleCatalogEntry
|
||||
if err := rows.Scan(&e.Role, &e.SourcePackageID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result = append(result, e)
|
||||
}
|
||||
return result, rows.Err()
|
||||
}
|
||||
|
||||
func (s *TeamStore) RemoveRoleCatalogBySource(ctx context.Context, teamID, sourcePkgID string) error {
|
||||
_, err := DB.ExecContext(ctx, `
|
||||
DELETE FROM team_role_catalog WHERE team_id = ? AND source_package_id = ?`,
|
||||
teamID, sourcePkgID)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user