Expose GET /admin/users/:user_id/subscriptions with full plan history and payments, and GET /admin/users/:user_id/learning-activity with LMS and exam-prep progress, completions, and recent timeline. Co-authored-by: Cursor <cursoragent@cursor.com>
116 lines
3.7 KiB
Go
116 lines
3.7 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
|
|
cc.id AS catalog_course_id,
|
|
cc.name AS catalog_course_name,
|
|
cc.sort_order AS catalog_course_sort_order,
|
|
u.id AS unit_id,
|
|
u.name AS unit_name,
|
|
u.sort_order 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 = 'PRACTICE'
|
|
AND qs.status = 'PUBLISHED'
|
|
INNER JOIN exam_prep.unit_module_lessons l ON l.id = p.unit_module_lesson_id
|
|
AND l.publish_status = 'PUBLISHED'
|
|
INNER JOIN exam_prep.unit_modules m ON m.id = l.unit_module_id
|
|
AND m.publish_status = 'PUBLISHED'
|
|
INNER JOIN exam_prep.units u ON u.id = m.unit_id
|
|
AND u.publish_status = 'PUBLISHED'
|
|
INNER JOIN exam_prep.catalog_courses cc ON cc.id = u.catalog_course_id
|
|
AND cc.publish_status = 'PUBLISHED'
|
|
WHERE
|
|
upp.user_id = $1
|
|
AND upp.completed_at IS NOT NULL
|
|
ORDER BY
|
|
cc.sort_order,
|
|
cc.id,
|
|
u.sort_order,
|
|
u.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 int64 `json:"unit_id"`
|
|
UnitName string `json:"unit_name"`
|
|
UnitSortOrder int32 `json:"unit_sort_order"`
|
|
ModuleID int64 `json:"module_id"`
|
|
ModuleName string `json:"module_name"`
|
|
ModuleSortOrder int32 `json:"module_sort_order"`
|
|
LessonID int64 `json:"lesson_id"`
|
|
LessonTitle string `json:"lesson_title"`
|
|
LessonSortOrder int32 `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
|
|
}
|