284 lines
8.8 KiB
Go
284 lines
8.8 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: learning_tree.sql
|
|
|
|
package dbgen
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const GetCourseLearningPath = `-- name: GetCourseLearningPath :many
|
|
SELECT
|
|
c.id AS course_id,
|
|
c.title AS course_title,
|
|
c.description AS course_description,
|
|
c.thumbnail AS course_thumbnail,
|
|
c.intro_video_url AS course_intro_video_url,
|
|
cc.id AS category_id,
|
|
cc.name AS category_name,
|
|
sc.id AS sub_course_id,
|
|
sc.title AS sub_course_title,
|
|
sc.description AS sub_course_description,
|
|
sc.thumbnail AS sub_course_thumbnail,
|
|
sc.display_order AS sub_course_display_order,
|
|
sc.level AS sub_course_level,
|
|
sc.sub_level AS sub_course_sub_level,
|
|
(SELECT COUNT(*) FROM sub_course_prerequisites WHERE sub_course_id = sc.id) AS prerequisite_count,
|
|
(SELECT COUNT(*) FROM sub_course_videos WHERE sub_course_id = sc.id AND status = 'PUBLISHED') AS video_count,
|
|
(SELECT COUNT(*) FROM question_sets WHERE set_type = 'PRACTICE' AND owner_type = 'SUB_COURSE' AND owner_id = sc.id AND status = 'PUBLISHED') AS practice_count
|
|
FROM courses c
|
|
JOIN course_categories cc ON cc.id = c.category_id
|
|
LEFT JOIN sub_courses sc ON sc.course_id = c.id AND sc.is_active = true
|
|
WHERE c.id = $1
|
|
ORDER BY sc.display_order, sc.id
|
|
`
|
|
|
|
type GetCourseLearningPathRow struct {
|
|
CourseID int64 `json:"course_id"`
|
|
CourseTitle string `json:"course_title"`
|
|
CourseDescription pgtype.Text `json:"course_description"`
|
|
CourseThumbnail pgtype.Text `json:"course_thumbnail"`
|
|
CourseIntroVideoUrl pgtype.Text `json:"course_intro_video_url"`
|
|
CategoryID int64 `json:"category_id"`
|
|
CategoryName string `json:"category_name"`
|
|
SubCourseID pgtype.Int8 `json:"sub_course_id"`
|
|
SubCourseTitle pgtype.Text `json:"sub_course_title"`
|
|
SubCourseDescription pgtype.Text `json:"sub_course_description"`
|
|
SubCourseThumbnail pgtype.Text `json:"sub_course_thumbnail"`
|
|
SubCourseDisplayOrder pgtype.Int4 `json:"sub_course_display_order"`
|
|
SubCourseLevel pgtype.Text `json:"sub_course_level"`
|
|
SubCourseSubLevel pgtype.Text `json:"sub_course_sub_level"`
|
|
PrerequisiteCount int64 `json:"prerequisite_count"`
|
|
VideoCount int64 `json:"video_count"`
|
|
PracticeCount int64 `json:"practice_count"`
|
|
}
|
|
|
|
func (q *Queries) GetCourseLearningPath(ctx context.Context, id int64) ([]GetCourseLearningPathRow, error) {
|
|
rows, err := q.db.Query(ctx, GetCourseLearningPath, id)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []GetCourseLearningPathRow
|
|
for rows.Next() {
|
|
var i GetCourseLearningPathRow
|
|
if err := rows.Scan(
|
|
&i.CourseID,
|
|
&i.CourseTitle,
|
|
&i.CourseDescription,
|
|
&i.CourseThumbnail,
|
|
&i.CourseIntroVideoUrl,
|
|
&i.CategoryID,
|
|
&i.CategoryName,
|
|
&i.SubCourseID,
|
|
&i.SubCourseTitle,
|
|
&i.SubCourseDescription,
|
|
&i.SubCourseThumbnail,
|
|
&i.SubCourseDisplayOrder,
|
|
&i.SubCourseLevel,
|
|
&i.SubCourseSubLevel,
|
|
&i.PrerequisiteCount,
|
|
&i.VideoCount,
|
|
&i.PracticeCount,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const GetFullLearningTree = `-- name: GetFullLearningTree :many
|
|
SELECT
|
|
c.id AS course_id,
|
|
c.title AS course_title,
|
|
sc.id AS sub_course_id,
|
|
sc.title AS sub_course_title,
|
|
sc.level AS sub_course_level,
|
|
sc.sub_level AS sub_course_sub_level
|
|
FROM courses c
|
|
LEFT JOIN sub_courses sc ON sc.course_id = c.id AND sc.is_active = true
|
|
WHERE c.is_active = true
|
|
ORDER BY c.id, sc.display_order, sc.id
|
|
`
|
|
|
|
type GetFullLearningTreeRow struct {
|
|
CourseID int64 `json:"course_id"`
|
|
CourseTitle string `json:"course_title"`
|
|
SubCourseID pgtype.Int8 `json:"sub_course_id"`
|
|
SubCourseTitle pgtype.Text `json:"sub_course_title"`
|
|
SubCourseLevel pgtype.Text `json:"sub_course_level"`
|
|
SubCourseSubLevel pgtype.Text `json:"sub_course_sub_level"`
|
|
}
|
|
|
|
func (q *Queries) GetFullLearningTree(ctx context.Context) ([]GetFullLearningTreeRow, error) {
|
|
rows, err := q.db.Query(ctx, GetFullLearningTree)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []GetFullLearningTreeRow
|
|
for rows.Next() {
|
|
var i GetFullLearningTreeRow
|
|
if err := rows.Scan(
|
|
&i.CourseID,
|
|
&i.CourseTitle,
|
|
&i.SubCourseID,
|
|
&i.SubCourseTitle,
|
|
&i.SubCourseLevel,
|
|
&i.SubCourseSubLevel,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const GetSubCoursePracticesForLearningPath = `-- name: GetSubCoursePracticesForLearningPath :many
|
|
SELECT id, title, description, persona, status,
|
|
(SELECT COUNT(*) FROM question_set_items WHERE set_id = qs.id) AS question_count
|
|
FROM question_sets qs
|
|
WHERE qs.owner_type = 'SUB_COURSE' AND qs.owner_id = $1
|
|
AND qs.set_type = 'PRACTICE' AND qs.status = 'PUBLISHED'
|
|
ORDER BY qs.display_order ASC, qs.created_at
|
|
`
|
|
|
|
type GetSubCoursePracticesForLearningPathRow struct {
|
|
ID int64 `json:"id"`
|
|
Title string `json:"title"`
|
|
Description pgtype.Text `json:"description"`
|
|
Persona pgtype.Text `json:"persona"`
|
|
Status string `json:"status"`
|
|
QuestionCount int64 `json:"question_count"`
|
|
}
|
|
|
|
func (q *Queries) GetSubCoursePracticesForLearningPath(ctx context.Context, ownerID pgtype.Int8) ([]GetSubCoursePracticesForLearningPathRow, error) {
|
|
rows, err := q.db.Query(ctx, GetSubCoursePracticesForLearningPath, ownerID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []GetSubCoursePracticesForLearningPathRow
|
|
for rows.Next() {
|
|
var i GetSubCoursePracticesForLearningPathRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Title,
|
|
&i.Description,
|
|
&i.Persona,
|
|
&i.Status,
|
|
&i.QuestionCount,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const GetSubCoursePrerequisitesForLearningPath = `-- name: GetSubCoursePrerequisitesForLearningPath :many
|
|
SELECT p.prerequisite_sub_course_id, sc.title, sc.level, sc.sub_level
|
|
FROM sub_course_prerequisites p
|
|
JOIN sub_courses sc ON sc.id = p.prerequisite_sub_course_id
|
|
WHERE p.sub_course_id = $1
|
|
ORDER BY sc.display_order
|
|
`
|
|
|
|
type GetSubCoursePrerequisitesForLearningPathRow struct {
|
|
PrerequisiteSubCourseID int64 `json:"prerequisite_sub_course_id"`
|
|
Title string `json:"title"`
|
|
Level string `json:"level"`
|
|
SubLevel string `json:"sub_level"`
|
|
}
|
|
|
|
func (q *Queries) GetSubCoursePrerequisitesForLearningPath(ctx context.Context, subCourseID int64) ([]GetSubCoursePrerequisitesForLearningPathRow, error) {
|
|
rows, err := q.db.Query(ctx, GetSubCoursePrerequisitesForLearningPath, subCourseID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []GetSubCoursePrerequisitesForLearningPathRow
|
|
for rows.Next() {
|
|
var i GetSubCoursePrerequisitesForLearningPathRow
|
|
if err := rows.Scan(
|
|
&i.PrerequisiteSubCourseID,
|
|
&i.Title,
|
|
&i.Level,
|
|
&i.SubLevel,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const GetSubCourseVideosForLearningPath = `-- name: GetSubCourseVideosForLearningPath :many
|
|
SELECT id, title, description, video_url, duration, resolution, display_order,
|
|
vimeo_id, vimeo_embed_url, video_host_provider
|
|
FROM sub_course_videos
|
|
WHERE sub_course_id = $1 AND status = 'PUBLISHED'
|
|
ORDER BY display_order, id
|
|
`
|
|
|
|
type GetSubCourseVideosForLearningPathRow struct {
|
|
ID int64 `json:"id"`
|
|
Title string `json:"title"`
|
|
Description pgtype.Text `json:"description"`
|
|
VideoUrl string `json:"video_url"`
|
|
Duration int32 `json:"duration"`
|
|
Resolution pgtype.Text `json:"resolution"`
|
|
DisplayOrder int32 `json:"display_order"`
|
|
VimeoID pgtype.Text `json:"vimeo_id"`
|
|
VimeoEmbedUrl pgtype.Text `json:"vimeo_embed_url"`
|
|
VideoHostProvider pgtype.Text `json:"video_host_provider"`
|
|
}
|
|
|
|
func (q *Queries) GetSubCourseVideosForLearningPath(ctx context.Context, subCourseID int64) ([]GetSubCourseVideosForLearningPathRow, error) {
|
|
rows, err := q.db.Query(ctx, GetSubCourseVideosForLearningPath, subCourseID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []GetSubCourseVideosForLearningPathRow
|
|
for rows.Next() {
|
|
var i GetSubCourseVideosForLearningPathRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Title,
|
|
&i.Description,
|
|
&i.VideoUrl,
|
|
&i.Duration,
|
|
&i.Resolution,
|
|
&i.DisplayOrder,
|
|
&i.VimeoID,
|
|
&i.VimeoEmbedUrl,
|
|
&i.VideoHostProvider,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|