feat: Update lesson query to filter by course through modules and implement Default for the Lesson struct.
This commit is contained in:
@@ -1942,7 +1942,7 @@ pub async fn get_recommendations(
|
||||
// I will assume the original query was correct for the schema in this environment.
|
||||
|
||||
let lessons = sqlx::query_as::<_, LessonContext>(
|
||||
"SELECT id, title, metadata FROM lessons WHERE course_id = $1",
|
||||
"SELECT l.id, l.title, l.metadata FROM lessons l JOIN modules m ON l.module_id = m.id WHERE m.course_id = $1",
|
||||
)
|
||||
.bind(course_id)
|
||||
.fetch_all(&pool)
|
||||
|
||||
@@ -64,6 +64,7 @@ pub struct Module {
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, sqlx::FromRow, Clone)]
|
||||
#[sqlx(default)]
|
||||
pub struct Lesson {
|
||||
pub id: Uuid,
|
||||
pub organization_id: Uuid,
|
||||
@@ -88,6 +89,34 @@ pub struct Lesson {
|
||||
pub created_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
impl Default for Lesson {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
id: Uuid::new_v4(),
|
||||
organization_id: Uuid::new_v4(),
|
||||
module_id: Uuid::new_v4(),
|
||||
title: String::new(),
|
||||
content_type: String::new(),
|
||||
content_url: None,
|
||||
summary: None,
|
||||
transcription: None,
|
||||
metadata: None,
|
||||
grading_category_id: None,
|
||||
is_graded: false,
|
||||
max_attempts: None,
|
||||
allow_retry: false,
|
||||
position: 0,
|
||||
due_date: None,
|
||||
important_date_type: None,
|
||||
transcription_status: None,
|
||||
video_generation_status: None,
|
||||
video_generation_error: None,
|
||||
is_previewable: false,
|
||||
created_at: Utc::now(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, sqlx::FromRow, Clone)]
|
||||
pub struct GradingCategory {
|
||||
pub id: Uuid,
|
||||
|
||||
Reference in New Issue
Block a user