139 lines
5.2 KiB
Go
139 lines
5.2 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: exam_prep_admin_activity.sql
|
|
|
|
package dbgen
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const ListUserExamPrepFlatLearningActivityByUser = `-- name: ListUserExamPrepFlatLearningActivityByUser :many
|
|
|
|
SELECT
|
|
COALESCE(cc_direct.id, cc_unit.id, cc_lesson.id) AS catalog_course_id,
|
|
COALESCE(cc_direct.name, cc_unit.name, cc_lesson.name) AS catalog_course_name,
|
|
COALESCE(cc_direct.sort_order, cc_unit.sort_order, cc_lesson.sort_order) AS catalog_course_sort_order,
|
|
CASE
|
|
WHEN pp.parent_kind = 'CATALOG_COURSE' THEN NULL::bigint
|
|
ELSE COALESCE(u_direct.id, u_lesson.id)
|
|
END AS unit_id,
|
|
CASE
|
|
WHEN pp.parent_kind = 'CATALOG_COURSE' THEN NULL::text
|
|
ELSE COALESCE(u_direct.name, u_lesson.name)
|
|
END AS unit_name,
|
|
CASE
|
|
WHEN pp.parent_kind = 'CATALOG_COURSE' THEN NULL::int
|
|
ELSE COALESCE(u_direct.sort_order, u_lesson.sort_order)
|
|
END AS unit_sort_order,
|
|
m.id AS module_id,
|
|
m.name AS module_name,
|
|
m.sort_order AS module_sort_order,
|
|
l.id AS lesson_id,
|
|
l.title AS lesson_title,
|
|
l.sort_order AS lesson_sort_order,
|
|
p.id AS exam_prep_practice_id,
|
|
p.title AS practice_title,
|
|
upp.completed_at AS activity_at
|
|
FROM
|
|
user_practice_progress upp
|
|
INNER JOIN exam_prep.lesson_practices p ON p.question_set_id = upp.question_set_id
|
|
AND p.publish_status = 'PUBLISHED'
|
|
INNER JOIN question_sets qs ON qs.id = p.question_set_id
|
|
AND qs.set_type IN ('PRACTICE', 'QUIZ')
|
|
AND qs.status = 'PUBLISHED'
|
|
INNER JOIN exam_prep.practice_parents pp ON pp.practice_id = p.id
|
|
AND upp.content_domain = 'EXAM_PREP'
|
|
AND upp.parent_kind = pp.parent_kind
|
|
AND upp.parent_id = pp.parent_id
|
|
LEFT JOIN exam_prep.unit_module_lessons l ON pp.parent_kind = 'LESSON'
|
|
AND l.id = pp.parent_id
|
|
AND l.publish_status = 'PUBLISHED'
|
|
LEFT JOIN exam_prep.unit_modules m ON l.unit_module_id = m.id
|
|
AND m.publish_status = 'PUBLISHED'
|
|
LEFT JOIN exam_prep.units u_lesson ON m.unit_id = u_lesson.id
|
|
AND u_lesson.publish_status = 'PUBLISHED'
|
|
LEFT JOIN exam_prep.catalog_courses cc_lesson ON u_lesson.catalog_course_id = cc_lesson.id
|
|
AND cc_lesson.publish_status = 'PUBLISHED'
|
|
LEFT JOIN exam_prep.units u_direct ON pp.parent_kind = 'UNIT'
|
|
AND u_direct.id = pp.parent_id
|
|
AND u_direct.publish_status = 'PUBLISHED'
|
|
LEFT JOIN exam_prep.catalog_courses cc_unit ON u_direct.catalog_course_id = cc_unit.id
|
|
AND cc_unit.publish_status = 'PUBLISHED'
|
|
LEFT JOIN exam_prep.catalog_courses cc_direct ON pp.parent_kind = 'CATALOG_COURSE'
|
|
AND cc_direct.id = pp.parent_id
|
|
AND cc_direct.publish_status = 'PUBLISHED'
|
|
WHERE
|
|
upp.user_id = $1
|
|
AND upp.completed_at IS NOT NULL
|
|
AND COALESCE(cc_direct.id, cc_unit.id, cc_lesson.id) IS NOT NULL
|
|
ORDER BY
|
|
COALESCE(cc_direct.sort_order, cc_unit.sort_order, cc_lesson.sort_order),
|
|
COALESCE(cc_direct.id, cc_unit.id, cc_lesson.id),
|
|
COALESCE(u_direct.sort_order, u_lesson.sort_order),
|
|
COALESCE(u_direct.id, u_lesson.id),
|
|
m.sort_order,
|
|
m.id,
|
|
l.sort_order,
|
|
l.id,
|
|
upp.completed_at
|
|
`
|
|
|
|
type ListUserExamPrepFlatLearningActivityByUserRow struct {
|
|
CatalogCourseID int64 `json:"catalog_course_id"`
|
|
CatalogCourseName string `json:"catalog_course_name"`
|
|
CatalogCourseSortOrder int32 `json:"catalog_course_sort_order"`
|
|
UnitID interface{} `json:"unit_id"`
|
|
UnitName interface{} `json:"unit_name"`
|
|
UnitSortOrder interface{} `json:"unit_sort_order"`
|
|
ModuleID pgtype.Int8 `json:"module_id"`
|
|
ModuleName pgtype.Text `json:"module_name"`
|
|
ModuleSortOrder pgtype.Int4 `json:"module_sort_order"`
|
|
LessonID pgtype.Int8 `json:"lesson_id"`
|
|
LessonTitle pgtype.Text `json:"lesson_title"`
|
|
LessonSortOrder pgtype.Int4 `json:"lesson_sort_order"`
|
|
ExamPrepPracticeID int64 `json:"exam_prep_practice_id"`
|
|
PracticeTitle string `json:"practice_title"`
|
|
ActivityAt pgtype.Timestamptz `json:"activity_at"`
|
|
}
|
|
|
|
// Exam-prep learning activity for admin: completed published practices grouped by hierarchy.
|
|
func (q *Queries) ListUserExamPrepFlatLearningActivityByUser(ctx context.Context, userID int64) ([]ListUserExamPrepFlatLearningActivityByUserRow, error) {
|
|
rows, err := q.db.Query(ctx, ListUserExamPrepFlatLearningActivityByUser, userID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []ListUserExamPrepFlatLearningActivityByUserRow
|
|
for rows.Next() {
|
|
var i ListUserExamPrepFlatLearningActivityByUserRow
|
|
if err := rows.Scan(
|
|
&i.CatalogCourseID,
|
|
&i.CatalogCourseName,
|
|
&i.CatalogCourseSortOrder,
|
|
&i.UnitID,
|
|
&i.UnitName,
|
|
&i.UnitSortOrder,
|
|
&i.ModuleID,
|
|
&i.ModuleName,
|
|
&i.ModuleSortOrder,
|
|
&i.LessonID,
|
|
&i.LessonTitle,
|
|
&i.LessonSortOrder,
|
|
&i.ExamPrepPracticeID,
|
|
&i.PracticeTitle,
|
|
&i.ActivityAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|