RezinaLMS-BackEnd/gen/db/exam_prep_practice_parents.sql.go
Yared Yemane 208c653e02 feat: attach exam prep practices to catalog courses and units
Introduce exam_prep.practice_parents, migrate lesson links, and add create/list APIs with progress rollups, sequential gating, and RBAC permissions.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-25 04:18:25 -07:00

189 lines
5.5 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.30.0
// source: exam_prep_practice_parents.sql
package dbgen
import (
"context"
)
const CountExamPrepPracticesByParent = `-- name: CountExamPrepPracticesByParent :one
SELECT COUNT(*)::bigint
FROM exam_prep.practice_parents
WHERE parent_kind = $1
AND parent_id = $2
`
type CountExamPrepPracticesByParentParams struct {
ParentKind string `json:"parent_kind"`
ParentID int64 `json:"parent_id"`
}
func (q *Queries) CountExamPrepPracticesByParent(ctx context.Context, arg CountExamPrepPracticesByParentParams) (int64, error) {
row := q.db.QueryRow(ctx, CountExamPrepPracticesByParent, arg.ParentKind, arg.ParentID)
var column_1 int64
err := row.Scan(&column_1)
return column_1, err
}
const CountExamPrepPracticesByParentExcludingPractice = `-- name: CountExamPrepPracticesByParentExcludingPractice :one
SELECT COUNT(*)::bigint
FROM exam_prep.practice_parents
WHERE parent_kind = $1
AND parent_id = $2
AND practice_id <> $3
`
type CountExamPrepPracticesByParentExcludingPracticeParams struct {
ParentKind string `json:"parent_kind"`
ParentID int64 `json:"parent_id"`
PracticeID int64 `json:"practice_id"`
}
func (q *Queries) CountExamPrepPracticesByParentExcludingPractice(ctx context.Context, arg CountExamPrepPracticesByParentExcludingPracticeParams) (int64, error) {
row := q.db.QueryRow(ctx, CountExamPrepPracticesByParentExcludingPractice, arg.ParentKind, arg.ParentID, arg.PracticeID)
var column_1 int64
err := row.Scan(&column_1)
return column_1, err
}
const DeleteExamPrepPracticeParentsByPracticeID = `-- name: DeleteExamPrepPracticeParentsByPracticeID :exec
DELETE FROM exam_prep.practice_parents
WHERE practice_id = $1
`
func (q *Queries) DeleteExamPrepPracticeParentsByPracticeID(ctx context.Context, practiceID int64) error {
_, err := q.db.Exec(ctx, DeleteExamPrepPracticeParentsByPracticeID, practiceID)
return err
}
const InsertExamPrepPracticeParent = `-- name: InsertExamPrepPracticeParent :one
INSERT INTO exam_prep.practice_parents (practice_id, parent_kind, parent_id)
VALUES ($1, $2, $3)
RETURNING id, practice_id, parent_kind, parent_id, created_at
`
type InsertExamPrepPracticeParentParams struct {
PracticeID int64 `json:"practice_id"`
ParentKind string `json:"parent_kind"`
ParentID int64 `json:"parent_id"`
}
func (q *Queries) InsertExamPrepPracticeParent(ctx context.Context, arg InsertExamPrepPracticeParentParams) (ExamPrepPracticeParent, error) {
row := q.db.QueryRow(ctx, InsertExamPrepPracticeParent, arg.PracticeID, arg.ParentKind, arg.ParentID)
var i ExamPrepPracticeParent
err := row.Scan(
&i.ID,
&i.PracticeID,
&i.ParentKind,
&i.ParentID,
&i.CreatedAt,
)
return i, err
}
const ListExamPrepPracticeParentsByPracticeID = `-- name: ListExamPrepPracticeParentsByPracticeID :many
SELECT id, practice_id, parent_kind, parent_id, created_at
FROM exam_prep.practice_parents
WHERE practice_id = $1
ORDER BY id ASC
`
func (q *Queries) ListExamPrepPracticeParentsByPracticeID(ctx context.Context, practiceID int64) ([]ExamPrepPracticeParent, error) {
rows, err := q.db.Query(ctx, ListExamPrepPracticeParentsByPracticeID, practiceID)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ExamPrepPracticeParent
for rows.Next() {
var i ExamPrepPracticeParent
if err := rows.Scan(
&i.ID,
&i.PracticeID,
&i.ParentKind,
&i.ParentID,
&i.CreatedAt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const ListExamPrepPracticeParentsByPracticeIDs = `-- name: ListExamPrepPracticeParentsByPracticeIDs :many
SELECT id, practice_id, parent_kind, parent_id, created_at
FROM exam_prep.practice_parents
WHERE practice_id = ANY ($1::bigint[])
ORDER BY practice_id ASC, id ASC
`
func (q *Queries) ListExamPrepPracticeParentsByPracticeIDs(ctx context.Context, practiceIds []int64) ([]ExamPrepPracticeParent, error) {
rows, err := q.db.Query(ctx, ListExamPrepPracticeParentsByPracticeIDs, practiceIds)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ExamPrepPracticeParent
for rows.Next() {
var i ExamPrepPracticeParent
if err := rows.Scan(
&i.ID,
&i.PracticeID,
&i.ParentKind,
&i.ParentID,
&i.CreatedAt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const ListExamPrepPracticeParentsByQuestionSetID = `-- name: ListExamPrepPracticeParentsByQuestionSetID :many
SELECT
pp.parent_kind,
pp.parent_id,
pp.practice_id
FROM exam_prep.practice_parents pp
INNER JOIN exam_prep.lesson_practices p ON p.id = pp.practice_id
WHERE p.question_set_id = $1
ORDER BY p.id DESC, pp.id ASC
`
type ListExamPrepPracticeParentsByQuestionSetIDRow struct {
ParentKind string `json:"parent_kind"`
ParentID int64 `json:"parent_id"`
PracticeID int64 `json:"practice_id"`
}
func (q *Queries) ListExamPrepPracticeParentsByQuestionSetID(ctx context.Context, questionSetID int64) ([]ListExamPrepPracticeParentsByQuestionSetIDRow, error) {
rows, err := q.db.Query(ctx, ListExamPrepPracticeParentsByQuestionSetID, questionSetID)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ListExamPrepPracticeParentsByQuestionSetIDRow
for rows.Next() {
var i ListExamPrepPracticeParentsByQuestionSetIDRow
if err := rows.Scan(&i.ParentKind, &i.ParentID, &i.PracticeID); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}