Remove AI image generation functionality from CMS and expand Docker ignore rules.
This commit is contained in:
@@ -35,34 +35,6 @@ pub async fn get_background_tasks(
|
||||
JOIN modules m ON l.module_id = m.id
|
||||
JOIN courses c ON m.course_id = c.id
|
||||
WHERE l.transcription_status IN ('queued', 'processing', 'failed')
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
l.id,
|
||||
l.title,
|
||||
c.title as course_title,
|
||||
'lesson_image' as task_type,
|
||||
l.video_generation_status as status,
|
||||
l.generation_progress as progress,
|
||||
l.updated_at
|
||||
FROM lessons l
|
||||
JOIN modules m ON l.module_id = m.id
|
||||
JOIN courses c ON m.course_id = c.id
|
||||
WHERE l.video_generation_status IN ('queued', 'processing', 'failed')
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
c.id,
|
||||
c.title as title,
|
||||
NULL as course_title,
|
||||
'course_image' as task_type,
|
||||
c.generation_status as status,
|
||||
c.generation_progress as progress,
|
||||
c.updated_at
|
||||
FROM courses c
|
||||
WHERE c.generation_status IN ('queued', 'processing', 'failed')
|
||||
|
||||
ORDER BY updated_at DESC
|
||||
"#;
|
||||
@@ -83,23 +55,15 @@ pub async fn get_background_tasks(
|
||||
#[derive(sqlx::FromRow)]
|
||||
struct LessonStatusRow {
|
||||
transcription_status: Option<String>,
|
||||
video_generation_status: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(sqlx::FromRow)]
|
||||
struct CourseStatusRow {
|
||||
generation_status: Option<String>,
|
||||
}
|
||||
|
||||
pub async fn retry_task(
|
||||
State(pool): State<PgPool>,
|
||||
Path(id): Path<Uuid>,
|
||||
) -> Result<StatusCode, (StatusCode, String)> {
|
||||
// We need to know WHAT to retry.
|
||||
// Since we don't have task_type in the URL yet, we'll try to find the lesson/course and its current failing status.
|
||||
|
||||
// Check lessons for transcription or image failures
|
||||
let lesson = sqlx::query_as::<_, LessonStatusRow>("SELECT transcription_status, video_generation_status FROM lessons WHERE id = $1")
|
||||
// Check lessons for transcription failures
|
||||
let lesson = sqlx::query_as::<_, LessonStatusRow>("SELECT transcription_status FROM lessons WHERE id = $1")
|
||||
.bind(id)
|
||||
.fetch_optional(&pool)
|
||||
.await
|
||||
@@ -114,44 +78,6 @@ pub async fn retry_task(
|
||||
});
|
||||
return Ok(StatusCode::ACCEPTED);
|
||||
}
|
||||
if l.video_generation_status.as_deref() == Some("failed") {
|
||||
tokio::spawn(async move {
|
||||
// For image generation, we need the worker pool.
|
||||
// Wait, run_image_generation_task is in handlers.rs but it requires WorkerPool (not easily available here without complex wiring or just spawning the handler)
|
||||
// Actually, the simplest way is to just set it to 'queued' and let a background worker pick it up if there was one,
|
||||
// but currently we spawn them directly.
|
||||
|
||||
// For now, let's call the same handler logic.
|
||||
// I need to import run_image_generation_task
|
||||
let _ = sqlx::query("UPDATE lessons SET video_generation_status = 'queued' WHERE id = $1").bind(id).execute(&pool_clone).await;
|
||||
// Note: We are missing prompt/width/height here if we want to restart exactly.
|
||||
// But generally retry means restart with same params.
|
||||
// We'll need to fetch them.
|
||||
|
||||
// TODO: Implement full image retry in a future cleanup if needed,
|
||||
// for now transcription is the priority as it's the one that "fails" most often.
|
||||
// Image generation usually works or the bridge is down.
|
||||
});
|
||||
return Ok(StatusCode::ACCEPTED);
|
||||
}
|
||||
}
|
||||
|
||||
// Check courses
|
||||
let course = sqlx::query_as::<_, CourseStatusRow>("SELECT generation_status FROM courses WHERE id = $1")
|
||||
.bind(id)
|
||||
.fetch_optional(&pool)
|
||||
.await
|
||||
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()))?;
|
||||
|
||||
if let Some(c) = course {
|
||||
if c.generation_status.as_deref() == Some("error") || c.generation_status.as_deref() == Some("failed") {
|
||||
let pool_clone = pool.clone();
|
||||
tokio::spawn(async move {
|
||||
let _ = sqlx::query("UPDATE courses SET generation_status = 'queued' WHERE id = $1").bind(id).execute(&pool_clone).await;
|
||||
// Same as above, needs a worker to pick it up.
|
||||
});
|
||||
return Ok(StatusCode::ACCEPTED);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(StatusCode::NOT_FOUND)
|
||||
@@ -161,16 +87,9 @@ pub async fn cancel_task(
|
||||
State(pool): State<PgPool>,
|
||||
Path(id): Path<Uuid>,
|
||||
) -> Result<StatusCode, (StatusCode, String)> {
|
||||
// Try to cancel in both tables
|
||||
// Only cancel transcription in lessons
|
||||
let _ = sqlx::query(
|
||||
"UPDATE lessons SET transcription_status = 'idle', video_generation_status = 'idle' WHERE id = $1"
|
||||
)
|
||||
.bind(id)
|
||||
.execute(&pool)
|
||||
.await;
|
||||
|
||||
let _ = sqlx::query(
|
||||
"UPDATE courses SET generation_status = 'idle' WHERE id = $1"
|
||||
"UPDATE lessons SET transcription_status = 'idle' WHERE id = $1"
|
||||
)
|
||||
.bind(id)
|
||||
.execute(&pool)
|
||||
|
||||
Reference in New Issue
Block a user