Introduce practice_stimulus_blocks, authoring_profile, and stimulus_block_key on question set items. Full practice GET/PUT returns merged effective_dynamic_payload for admin authoring. Co-authored-by: Cursor <cursoragent@cursor.com>
141 lines
3.7 KiB
Go
141 lines
3.7 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: practice_stimulus_blocks.sql
|
|
|
|
package dbgen
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const DeleteAllPracticeStimulusBlocks = `-- name: DeleteAllPracticeStimulusBlocks :exec
|
|
DELETE FROM practice_stimulus_blocks
|
|
WHERE practice_kind = $1
|
|
AND practice_id = $2
|
|
`
|
|
|
|
type DeleteAllPracticeStimulusBlocksParams struct {
|
|
PracticeKind string `json:"practice_kind"`
|
|
PracticeID int64 `json:"practice_id"`
|
|
}
|
|
|
|
func (q *Queries) DeleteAllPracticeStimulusBlocks(ctx context.Context, arg DeleteAllPracticeStimulusBlocksParams) error {
|
|
_, err := q.db.Exec(ctx, DeleteAllPracticeStimulusBlocks, arg.PracticeKind, arg.PracticeID)
|
|
return err
|
|
}
|
|
|
|
const DeletePracticeStimulusBlocksNotInKeys = `-- name: DeletePracticeStimulusBlocksNotInKeys :exec
|
|
DELETE FROM practice_stimulus_blocks
|
|
WHERE practice_kind = $1
|
|
AND practice_id = $2
|
|
AND (
|
|
cardinality($3::varchar[]) = 0
|
|
OR block_key != ALL ($3::varchar[])
|
|
)
|
|
`
|
|
|
|
type DeletePracticeStimulusBlocksNotInKeysParams struct {
|
|
PracticeKind string `json:"practice_kind"`
|
|
PracticeID int64 `json:"practice_id"`
|
|
BlockKeys []string `json:"block_keys"`
|
|
}
|
|
|
|
func (q *Queries) DeletePracticeStimulusBlocksNotInKeys(ctx context.Context, arg DeletePracticeStimulusBlocksNotInKeysParams) error {
|
|
_, err := q.db.Exec(ctx, DeletePracticeStimulusBlocksNotInKeys, arg.PracticeKind, arg.PracticeID, arg.BlockKeys)
|
|
return err
|
|
}
|
|
|
|
const ListPracticeStimulusBlocks = `-- name: ListPracticeStimulusBlocks :many
|
|
SELECT id, practice_kind, practice_id, block_key, stimulus, display_order, created_at, updated_at
|
|
FROM practice_stimulus_blocks
|
|
WHERE practice_kind = $1
|
|
AND practice_id = $2
|
|
ORDER BY display_order, id
|
|
`
|
|
|
|
type ListPracticeStimulusBlocksParams struct {
|
|
PracticeKind string `json:"practice_kind"`
|
|
PracticeID int64 `json:"practice_id"`
|
|
}
|
|
|
|
func (q *Queries) ListPracticeStimulusBlocks(ctx context.Context, arg ListPracticeStimulusBlocksParams) ([]PracticeStimulusBlock, error) {
|
|
rows, err := q.db.Query(ctx, ListPracticeStimulusBlocks, arg.PracticeKind, arg.PracticeID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []PracticeStimulusBlock
|
|
for rows.Next() {
|
|
var i PracticeStimulusBlock
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.PracticeKind,
|
|
&i.PracticeID,
|
|
&i.BlockKey,
|
|
&i.Stimulus,
|
|
&i.DisplayOrder,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const UpsertPracticeStimulusBlock = `-- name: UpsertPracticeStimulusBlock :one
|
|
INSERT INTO practice_stimulus_blocks (
|
|
practice_kind,
|
|
practice_id,
|
|
block_key,
|
|
stimulus,
|
|
display_order
|
|
) VALUES (
|
|
$1,
|
|
$2,
|
|
$3,
|
|
$4,
|
|
$5
|
|
)
|
|
ON CONFLICT (practice_kind, practice_id, block_key) DO UPDATE SET
|
|
stimulus = EXCLUDED.stimulus,
|
|
display_order = EXCLUDED.display_order,
|
|
updated_at = CURRENT_TIMESTAMP
|
|
RETURNING id, practice_kind, practice_id, block_key, stimulus, display_order, created_at, updated_at
|
|
`
|
|
|
|
type UpsertPracticeStimulusBlockParams struct {
|
|
PracticeKind string `json:"practice_kind"`
|
|
PracticeID int64 `json:"practice_id"`
|
|
BlockKey string `json:"block_key"`
|
|
Stimulus []byte `json:"stimulus"`
|
|
DisplayOrder int32 `json:"display_order"`
|
|
}
|
|
|
|
func (q *Queries) UpsertPracticeStimulusBlock(ctx context.Context, arg UpsertPracticeStimulusBlockParams) (PracticeStimulusBlock, error) {
|
|
row := q.db.QueryRow(ctx, UpsertPracticeStimulusBlock,
|
|
arg.PracticeKind,
|
|
arg.PracticeID,
|
|
arg.BlockKey,
|
|
arg.Stimulus,
|
|
arg.DisplayOrder,
|
|
)
|
|
var i PracticeStimulusBlock
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.PracticeKind,
|
|
&i.PracticeID,
|
|
&i.BlockKey,
|
|
&i.Stimulus,
|
|
&i.DisplayOrder,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|