@@ -100,43 +100,6 @@ WHERE
|
||||
return err
|
||||
}
|
||||
|
||||
func (cms *ControlMeasures) LoadByMeasureID(
|
||||
ctx context.Context,
|
||||
conn pg.Conn,
|
||||
scope Scoper,
|
||||
measureID gid.GID,
|
||||
) error {
|
||||
q := `
|
||||
SELECT
|
||||
control_id,
|
||||
measure_id,
|
||||
tenant_id,
|
||||
created_at
|
||||
FROM
|
||||
controls_measures
|
||||
WHERE
|
||||
%s
|
||||
AND measure_id = @measure_id
|
||||
`
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.StrictNamedArgs{"measure_id": measureID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot query control_measures: %w", err)
|
||||
}
|
||||
|
||||
controlMeasures, err := pgx.CollectRows(rows, pgx.RowToAddrOfStructByName[ControlMeasure])
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot collect control_measures: %w", err)
|
||||
}
|
||||
|
||||
*cms = controlMeasures
|
||||
return nil
|
||||
}
|
||||
|
||||
type ControlWithRisk struct {
|
||||
ControlID gid.GID `db:"control_id"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user