// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.30.0 // source: lms_practices.sql package dbgen import ( "context" "github.com/jackc/pgx/v5/pgtype" ) const CountLmsPracticesByCourseID = `-- name: CountLmsPracticesByCourseID :one SELECT COUNT(*)::bigint FROM lms_practice_parents WHERE parent_kind = 'COURSE' AND parent_id = $1 ` func (q *Queries) CountLmsPracticesByCourseID(ctx context.Context, parentID int64) (int64, error) { row := q.db.QueryRow(ctx, CountLmsPracticesByCourseID, parentID) var column_1 int64 err := row.Scan(&column_1) return column_1, err } const CountLmsPracticesByLessonID = `-- name: CountLmsPracticesByLessonID :one SELECT COUNT(*)::bigint FROM lms_practice_parents WHERE parent_kind = 'LESSON' AND parent_id = $1 ` func (q *Queries) CountLmsPracticesByLessonID(ctx context.Context, parentID int64) (int64, error) { row := q.db.QueryRow(ctx, CountLmsPracticesByLessonID, parentID) var column_1 int64 err := row.Scan(&column_1) return column_1, err } const CountLmsPracticesByModuleID = `-- name: CountLmsPracticesByModuleID :one SELECT COUNT(*)::bigint FROM lms_practice_parents WHERE parent_kind = 'MODULE' AND parent_id = $1 ` func (q *Queries) CountLmsPracticesByModuleID(ctx context.Context, parentID int64) (int64, error) { row := q.db.QueryRow(ctx, CountLmsPracticesByModuleID, parentID) var column_1 int64 err := row.Scan(&column_1) return column_1, err } const CreateLmsPractice = `-- name: CreateLmsPractice :one INSERT INTO lms_practices ( title, story_description, story_image, persona_id, question_set_id, quick_tips, publish_status ) VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING id, title, story_description, story_image, persona_id, question_set_id, quick_tips, created_at, updated_at, publish_status, authoring_profile ` type CreateLmsPracticeParams struct { Title string `json:"title"` StoryDescription pgtype.Text `json:"story_description"` StoryImage pgtype.Text `json:"story_image"` PersonaID pgtype.Int8 `json:"persona_id"` QuestionSetID int64 `json:"question_set_id"` QuickTips pgtype.Text `json:"quick_tips"` PublishStatus string `json:"publish_status"` } func (q *Queries) CreateLmsPractice(ctx context.Context, arg CreateLmsPracticeParams) (LmsPractice, error) { row := q.db.QueryRow(ctx, CreateLmsPractice, arg.Title, arg.StoryDescription, arg.StoryImage, arg.PersonaID, arg.QuestionSetID, arg.QuickTips, arg.PublishStatus, ) var i LmsPractice err := row.Scan( &i.ID, &i.Title, &i.StoryDescription, &i.StoryImage, &i.PersonaID, &i.QuestionSetID, &i.QuickTips, &i.CreatedAt, &i.UpdatedAt, &i.PublishStatus, &i.AuthoringProfile, ) return i, err } const DeleteLmsPractice = `-- name: DeleteLmsPractice :exec DELETE FROM lms_practices WHERE id = $1 ` func (q *Queries) DeleteLmsPractice(ctx context.Context, id int64) error { _, err := q.db.Exec(ctx, DeleteLmsPractice, id) return err } const GetLmsPracticeByID = `-- name: GetLmsPracticeByID :one SELECT id, title, story_description, story_image, persona_id, question_set_id, quick_tips, created_at, updated_at, publish_status, authoring_profile FROM lms_practices WHERE id = $1 ` func (q *Queries) GetLmsPracticeByID(ctx context.Context, id int64) (LmsPractice, error) { row := q.db.QueryRow(ctx, GetLmsPracticeByID, id) var i LmsPractice err := row.Scan( &i.ID, &i.Title, &i.StoryDescription, &i.StoryImage, &i.PersonaID, &i.QuestionSetID, &i.QuickTips, &i.CreatedAt, &i.UpdatedAt, &i.PublishStatus, &i.AuthoringProfile, ) return i, err } const GetLmsPracticeByQuestionSetID = `-- name: GetLmsPracticeByQuestionSetID :one SELECT id, title, story_description, story_image, persona_id, question_set_id, quick_tips, created_at, updated_at, publish_status, authoring_profile FROM lms_practices WHERE question_set_id = $1 ORDER BY id DESC LIMIT 1 ` func (q *Queries) GetLmsPracticeByQuestionSetID(ctx context.Context, questionSetID int64) (LmsPractice, error) { row := q.db.QueryRow(ctx, GetLmsPracticeByQuestionSetID, questionSetID) var i LmsPractice err := row.Scan( &i.ID, &i.Title, &i.StoryDescription, &i.StoryImage, &i.PersonaID, &i.QuestionSetID, &i.QuickTips, &i.CreatedAt, &i.UpdatedAt, &i.PublishStatus, &i.AuthoringProfile, ) return i, err } const ListAllLmsPractices = `-- name: ListAllLmsPractices :many SELECT COUNT(*) OVER () AS total_count, p.id, p.title, p.story_description, p.story_image, p.persona_id, p.question_set_id, p.quick_tips, p.publish_status, p.created_at, p.updated_at FROM lms_practices p WHERE ( $3::boolean = FALSE OR p.publish_status = 'PUBLISHED'::TEXT ) AND ( $4::boolean = FALSE OR NOT EXISTS ( SELECT 1 FROM lms_practice_parents lpp WHERE lpp.practice_id = p.id ) ) ORDER BY p.created_at DESC LIMIT $1 OFFSET $2 ` type ListAllLmsPracticesParams struct { Limit int32 `json:"limit"` Offset int32 `json:"offset"` PublishedOnly bool `json:"published_only"` UnlinkedOnly bool `json:"unlinked_only"` } type ListAllLmsPracticesRow struct { TotalCount int64 `json:"total_count"` ID int64 `json:"id"` Title string `json:"title"` StoryDescription pgtype.Text `json:"story_description"` StoryImage pgtype.Text `json:"story_image"` PersonaID pgtype.Int8 `json:"persona_id"` QuestionSetID int64 `json:"question_set_id"` QuickTips pgtype.Text `json:"quick_tips"` PublishStatus string `json:"publish_status"` CreatedAt pgtype.Timestamptz `json:"created_at"` UpdatedAt pgtype.Timestamptz `json:"updated_at"` } func (q *Queries) ListAllLmsPractices(ctx context.Context, arg ListAllLmsPracticesParams) ([]ListAllLmsPracticesRow, error) { rows, err := q.db.Query(ctx, ListAllLmsPractices, arg.Limit, arg.Offset, arg.PublishedOnly, arg.UnlinkedOnly, ) if err != nil { return nil, err } defer rows.Close() var items []ListAllLmsPracticesRow for rows.Next() { var i ListAllLmsPracticesRow if err := rows.Scan( &i.TotalCount, &i.ID, &i.Title, &i.StoryDescription, &i.StoryImage, &i.PersonaID, &i.QuestionSetID, &i.QuickTips, &i.PublishStatus, &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 ListLmsPracticesByCourseID = `-- name: ListLmsPracticesByCourseID :many SELECT COUNT(*) OVER () AS total_count, p.id, p.title, p.story_description, p.story_image, p.persona_id, p.question_set_id, p.quick_tips, p.publish_status, p.created_at, p.updated_at FROM lms_practices p INNER JOIN lms_practice_parents lpp ON lpp.practice_id = p.id WHERE lpp.parent_kind = 'COURSE' AND lpp.parent_id = $1 AND ( $2::boolean = FALSE OR p.publish_status = 'PUBLISHED'::TEXT ) ORDER BY p.created_at DESC LIMIT $4 OFFSET $3 ` type ListLmsPracticesByCourseIDParams struct { ParentID int64 `json:"parent_id"` PublishedOnly bool `json:"published_only"` Offset int32 `json:"offset"` Limit int32 `json:"limit"` } type ListLmsPracticesByCourseIDRow struct { TotalCount int64 `json:"total_count"` ID int64 `json:"id"` Title string `json:"title"` StoryDescription pgtype.Text `json:"story_description"` StoryImage pgtype.Text `json:"story_image"` PersonaID pgtype.Int8 `json:"persona_id"` QuestionSetID int64 `json:"question_set_id"` QuickTips pgtype.Text `json:"quick_tips"` PublishStatus string `json:"publish_status"` CreatedAt pgtype.Timestamptz `json:"created_at"` UpdatedAt pgtype.Timestamptz `json:"updated_at"` } func (q *Queries) ListLmsPracticesByCourseID(ctx context.Context, arg ListLmsPracticesByCourseIDParams) ([]ListLmsPracticesByCourseIDRow, error) { rows, err := q.db.Query(ctx, ListLmsPracticesByCourseID, arg.ParentID, arg.PublishedOnly, arg.Offset, arg.Limit, ) if err != nil { return nil, err } defer rows.Close() var items []ListLmsPracticesByCourseIDRow for rows.Next() { var i ListLmsPracticesByCourseIDRow if err := rows.Scan( &i.TotalCount, &i.ID, &i.Title, &i.StoryDescription, &i.StoryImage, &i.PersonaID, &i.QuestionSetID, &i.QuickTips, &i.PublishStatus, &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 ListLmsPracticesByLessonID = `-- name: ListLmsPracticesByLessonID :many SELECT COUNT(*) OVER () AS total_count, p.id, p.title, p.story_description, p.story_image, p.persona_id, p.question_set_id, p.quick_tips, p.publish_status, p.created_at, p.updated_at FROM lms_practices p INNER JOIN lms_practice_parents lpp ON lpp.practice_id = p.id WHERE lpp.parent_kind = 'LESSON' AND lpp.parent_id = $1 AND ( $4::boolean = FALSE OR p.publish_status = 'PUBLISHED'::TEXT ) ORDER BY p.created_at DESC LIMIT $2 OFFSET $3 ` type ListLmsPracticesByLessonIDParams struct { ParentID int64 `json:"parent_id"` Limit int32 `json:"limit"` Offset int32 `json:"offset"` PublishedOnly bool `json:"published_only"` } type ListLmsPracticesByLessonIDRow struct { TotalCount int64 `json:"total_count"` ID int64 `json:"id"` Title string `json:"title"` StoryDescription pgtype.Text `json:"story_description"` StoryImage pgtype.Text `json:"story_image"` PersonaID pgtype.Int8 `json:"persona_id"` QuestionSetID int64 `json:"question_set_id"` QuickTips pgtype.Text `json:"quick_tips"` PublishStatus string `json:"publish_status"` CreatedAt pgtype.Timestamptz `json:"created_at"` UpdatedAt pgtype.Timestamptz `json:"updated_at"` } func (q *Queries) ListLmsPracticesByLessonID(ctx context.Context, arg ListLmsPracticesByLessonIDParams) ([]ListLmsPracticesByLessonIDRow, error) { rows, err := q.db.Query(ctx, ListLmsPracticesByLessonID, arg.ParentID, arg.Limit, arg.Offset, arg.PublishedOnly, ) if err != nil { return nil, err } defer rows.Close() var items []ListLmsPracticesByLessonIDRow for rows.Next() { var i ListLmsPracticesByLessonIDRow if err := rows.Scan( &i.TotalCount, &i.ID, &i.Title, &i.StoryDescription, &i.StoryImage, &i.PersonaID, &i.QuestionSetID, &i.QuickTips, &i.PublishStatus, &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 ListLmsPracticesByModuleID = `-- name: ListLmsPracticesByModuleID :many SELECT COUNT(*) OVER () AS total_count, p.id, p.title, p.story_description, p.story_image, p.persona_id, p.question_set_id, p.quick_tips, p.publish_status, p.created_at, p.updated_at FROM lms_practices p INNER JOIN lms_practice_parents lpp ON lpp.practice_id = p.id WHERE lpp.parent_kind = 'MODULE' AND lpp.parent_id = $1 AND ( $2::boolean = FALSE OR p.publish_status = 'PUBLISHED'::TEXT ) ORDER BY p.created_at DESC LIMIT $4 OFFSET $3 ` type ListLmsPracticesByModuleIDParams struct { ParentID int64 `json:"parent_id"` PublishedOnly bool `json:"published_only"` Offset int32 `json:"offset"` Limit int32 `json:"limit"` } type ListLmsPracticesByModuleIDRow struct { TotalCount int64 `json:"total_count"` ID int64 `json:"id"` Title string `json:"title"` StoryDescription pgtype.Text `json:"story_description"` StoryImage pgtype.Text `json:"story_image"` PersonaID pgtype.Int8 `json:"persona_id"` QuestionSetID int64 `json:"question_set_id"` QuickTips pgtype.Text `json:"quick_tips"` PublishStatus string `json:"publish_status"` CreatedAt pgtype.Timestamptz `json:"created_at"` UpdatedAt pgtype.Timestamptz `json:"updated_at"` } func (q *Queries) ListLmsPracticesByModuleID(ctx context.Context, arg ListLmsPracticesByModuleIDParams) ([]ListLmsPracticesByModuleIDRow, error) { rows, err := q.db.Query(ctx, ListLmsPracticesByModuleID, arg.ParentID, arg.PublishedOnly, arg.Offset, arg.Limit, ) if err != nil { return nil, err } defer rows.Close() var items []ListLmsPracticesByModuleIDRow for rows.Next() { var i ListLmsPracticesByModuleIDRow if err := rows.Scan( &i.TotalCount, &i.ID, &i.Title, &i.StoryDescription, &i.StoryImage, &i.PersonaID, &i.QuestionSetID, &i.QuickTips, &i.PublishStatus, &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 UpdateLmsPractice = `-- name: UpdateLmsPractice :one UPDATE lms_practices SET title = COALESCE($1::varchar, title), story_description = COALESCE($2::text, story_description), story_image = COALESCE($3::text, story_image), persona_id = COALESCE($4::bigint, persona_id), question_set_id = COALESCE($5::bigint, question_set_id), quick_tips = COALESCE($6::text, quick_tips), publish_status = COALESCE($7::varchar, publish_status), authoring_profile = COALESCE($8::varchar, authoring_profile), updated_at = CURRENT_TIMESTAMP WHERE id = $9 RETURNING id, title, story_description, story_image, persona_id, question_set_id, quick_tips, created_at, updated_at, publish_status, authoring_profile ` type UpdateLmsPracticeParams struct { Title pgtype.Text `json:"title"` StoryDescription pgtype.Text `json:"story_description"` StoryImage pgtype.Text `json:"story_image"` PersonaID pgtype.Int8 `json:"persona_id"` QuestionSetID pgtype.Int8 `json:"question_set_id"` QuickTips pgtype.Text `json:"quick_tips"` PublishStatus pgtype.Text `json:"publish_status"` AuthoringProfile pgtype.Text `json:"authoring_profile"` ID int64 `json:"id"` } func (q *Queries) UpdateLmsPractice(ctx context.Context, arg UpdateLmsPracticeParams) (LmsPractice, error) { row := q.db.QueryRow(ctx, UpdateLmsPractice, arg.Title, arg.StoryDescription, arg.StoryImage, arg.PersonaID, arg.QuestionSetID, arg.QuickTips, arg.PublishStatus, arg.AuthoringProfile, arg.ID, ) var i LmsPractice err := row.Scan( &i.ID, &i.Title, &i.StoryDescription, &i.StoryImage, &i.PersonaID, &i.QuestionSetID, &i.QuickTips, &i.CreatedAt, &i.UpdatedAt, &i.PublishStatus, &i.AuthoringProfile, ) return i, err }