@@ -134,7 +134,7 @@ LIMIT 1;
|
||||
`
|
||||
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
|
||||
args := pgx.NamedArgs{"framework_id": frameworkID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
r := conn.QueryRow(ctx, q, args)
|
||||
|
||||
@@ -16,9 +16,9 @@ package coredata
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
"maps"
|
||||
"fmt"
|
||||
"maps"
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
"go.gearno.de/kit/pg"
|
||||
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
)
|
||||
|
||||
type (
|
||||
Scope struct {}
|
||||
Scope struct{}
|
||||
)
|
||||
|
||||
func NewScope() *Scope {
|
||||
|
||||
@@ -24,14 +24,14 @@ import (
|
||||
|
||||
type (
|
||||
Service struct {
|
||||
pg *pg.Client
|
||||
pg *pg.Client
|
||||
scope *coredata.Scope
|
||||
}
|
||||
)
|
||||
|
||||
func NewService(ctx context.Context, pgClient *pg.Client) *Service {
|
||||
return &Service{
|
||||
pg: pgClient,
|
||||
pg: pgClient,
|
||||
scope: coredata.NewScope(), // must be created from auth
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,12 @@ func (s *Service) GetOrganization(
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
return organization.LoadByID(ctx, conn, s.scope, organizationID)
|
||||
return organization.LoadByID(
|
||||
ctx,
|
||||
conn,
|
||||
s.scope,
|
||||
organizationID,
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
@@ -66,7 +71,13 @@ func (s *Service) ListOrganizationFrameworks(
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
return frameworks.LoadByOrganizationID(ctx, conn, s.scope, organizationID, cursor)
|
||||
return frameworks.LoadByOrganizationID(
|
||||
ctx,
|
||||
conn,
|
||||
s.scope,
|
||||
organizationID,
|
||||
cursor,
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
@@ -87,7 +98,13 @@ func (s *Service) ListFrameworkControls(
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
return controls.LoadByFrameworkID(ctx, conn, s.scope, frameworkID, cursor)
|
||||
return controls.LoadByFrameworkID(
|
||||
ctx,
|
||||
conn,
|
||||
s.scope,
|
||||
frameworkID,
|
||||
cursor,
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
@@ -108,7 +125,13 @@ func (s *Service) ListControlTasks(
|
||||
err := s.pg.WithConn(
|
||||
ctx,
|
||||
func(conn pg.Conn) error {
|
||||
return tasks.LoadByControlID(ctx, conn, s.scope, controlID, cursor)
|
||||
return tasks.LoadByControlID(
|
||||
ctx,
|
||||
conn,
|
||||
s.scope,
|
||||
controlID,
|
||||
cursor,
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user