@@ -95,78 +95,6 @@ WHERE
|
||||
return err
|
||||
}
|
||||
|
||||
func (cos *ControlObligations) LoadByControlID(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
controlID gid.GID,
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
control_id,
|
||||
obligation_id,
|
||||
created_at
|
||||
FROM
|
||||
controls_obligations
|
||||
WHERE
|
||||
%s
|
||||
AND control_id = @control_id
|
||||
`
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"control_id": controlID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query control_obligations: %w", err)
|
||||
}
|
||||
|
||||
controlObligations, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[ControlObligation])
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot collect control_obligations: %w", err)
|
||||
}
|
||||
|
||||
*cos = controlObligations
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cos *ControlObligations) LoadByObligationID(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
obligationID gid.GID,
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
control_id,
|
||||
obligation_id,
|
||||
created_at
|
||||
FROM
|
||||
controls_obligations
|
||||
WHERE
|
||||
%s
|
||||
AND obligation_id = @obligation_id
|
||||
`
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"obligation_id": obligationID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query control_obligations: %w", err)
|
||||
}
|
||||
|
||||
controlObligations, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[ControlObligation])
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot collect control_obligations: %w", err)
|
||||
}
|
||||
|
||||
*cos = controlObligations
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cos *ControlObligations) CountByControlID(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
|
||||
Reference in New Issue
Block a user