From c292efdc28ec250d919fd5ec493251cb01910610 Mon Sep 17 00:00:00 2001 From: Nurfog Date: Mon, 9 Mar 2026 10:52:57 -0300 Subject: [PATCH] refactor: remove obsolete AI image and video generation traces from courses and lessons. --- ...20260309000000_cleanup_ai_image_traces.sql | 47 +++++++++++++++++++ services/cms-service/src/handlers.rs | 9 +--- services/cms-service/src/handlers/tasks.rs | 2 +- shared/common/src/models.rs | 8 ---- web/studio/src/lib/api.ts | 3 -- 5 files changed, 49 insertions(+), 20 deletions(-) create mode 100644 services/cms-service/migrations/20260309000000_cleanup_ai_image_traces.sql diff --git a/services/cms-service/migrations/20260309000000_cleanup_ai_image_traces.sql b/services/cms-service/migrations/20260309000000_cleanup_ai_image_traces.sql new file mode 100644 index 0000000..e85e1ef --- /dev/null +++ b/services/cms-service/migrations/20260309000000_cleanup_ai_image_traces.sql @@ -0,0 +1,47 @@ +-- Migration: Remove obsolete AI image generation traces +-- 1. Drop columns from courses +ALTER TABLE courses +DROP COLUMN IF EXISTS generation_status, +DROP COLUMN IF EXISTS generation_progress, +DROP COLUMN IF EXISTS generation_error; + +-- 2. Drop columns from lessons +ALTER TABLE lessons +DROP COLUMN IF EXISTS video_generation_status, +DROP COLUMN IF EXISTS video_generation_error; + +-- 3. Update fn_update_course to remove p_generation_status +CREATE OR REPLACE FUNCTION fn_update_course( + p_id UUID, + p_organization_id UUID, + p_title VARCHAR(255), + p_description TEXT, + p_passing_percentage INTEGER, + p_pacing_mode VARCHAR(50), + p_start_date TIMESTAMPTZ, + p_end_date TIMESTAMPTZ, + p_certificate_template VARCHAR(255) DEFAULT NULL, + p_price DOUBLE PRECISION DEFAULT 0.0, + p_currency VARCHAR(10) DEFAULT 'USD', + p_marketing_metadata JSONB DEFAULT NULL, + p_course_image_url TEXT DEFAULT NULL +) RETURNS SETOF courses AS $$ +BEGIN + RETURN QUERY + UPDATE courses + SET title = COALESCE(p_title, title), + description = COALESCE(p_description, description), + passing_percentage = COALESCE(p_passing_percentage, passing_percentage), + pacing_mode = COALESCE(p_pacing_mode, pacing_mode), + start_date = p_start_date, + end_date = p_end_date, + certificate_template = COALESCE(p_certificate_template, certificate_template), + price = COALESCE(p_price, price), + currency = COALESCE(p_currency, currency), + marketing_metadata = COALESCE(p_marketing_metadata, marketing_metadata), + course_image_url = COALESCE(p_course_image_url, course_image_url), + updated_at = NOW() + WHERE id = p_id AND organization_id = p_organization_id + RETURNING *; +END; +$$ LANGUAGE plpgsql; diff --git a/services/cms-service/src/handlers.rs b/services/cms-service/src/handlers.rs index 90dbf18..2751711 100644 --- a/services/cms-service/src/handlers.rs +++ b/services/cms-service/src/handlers.rs @@ -419,12 +419,6 @@ pub async fn update_course( .map(|s| s.to_string()) .or(existing.course_image_url); - let generation_status = payload - .get("generation_status") - .and_then(|v| v.as_str()) - .map(|s| s.to_string()) - .or(existing.generation_status); - // BEGIN TRANSACTION let mut tx = pool .begin() @@ -442,7 +436,7 @@ pub async fn update_course( .map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()))?; let course = sqlx::query_as::<_, Course>( - "SELECT * FROM fn_update_course($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14)", + "SELECT * FROM fn_update_course($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)", ) .bind(id) .bind(org_ctx.id) @@ -457,7 +451,6 @@ pub async fn update_course( .bind(currency) .bind(marketing_metadata) .bind(course_image_url) - .bind(generation_status) .fetch_one(&mut *tx) .await .map_err(|e| { diff --git a/services/cms-service/src/handlers/tasks.rs b/services/cms-service/src/handlers/tasks.rs index e2efb5f..44f2d30 100644 --- a/services/cms-service/src/handlers/tasks.rs +++ b/services/cms-service/src/handlers/tasks.rs @@ -13,7 +13,7 @@ pub struct BackgroundTask { pub id: Uuid, pub title: String, pub course_title: Option, - pub task_type: String, // 'transcription', 'lesson_image', 'course_image' + pub task_type: String, // 'transcription' pub status: String, pub progress: i32, pub updated_at: chrono::DateTime, diff --git a/shared/common/src/models.rs b/shared/common/src/models.rs index 36933af..6ee168a 100644 --- a/shared/common/src/models.rs +++ b/shared/common/src/models.rs @@ -20,9 +20,6 @@ pub struct Course { pub currency: String, pub marketing_metadata: Option, pub course_image_url: Option, - pub generation_status: Option, - pub generation_progress: Option, - pub generation_error: Option, pub created_at: DateTime, pub updated_at: DateTime, } @@ -44,9 +41,6 @@ impl Default for Course { currency: "USD".to_string(), marketing_metadata: None, course_image_url: None, - generation_status: None, - generation_progress: None, - generation_error: None, created_at: Utc::now(), updated_at: Utc::now(), } @@ -107,8 +101,6 @@ impl Default for Lesson { 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(), } diff --git a/web/studio/src/lib/api.ts b/web/studio/src/lib/api.ts index 81a5027..baa9784 100644 --- a/web/studio/src/lib/api.ts +++ b/web/studio/src/lib/api.ts @@ -45,9 +45,6 @@ export interface Course { certification_info?: string; }; course_image_url?: string; - generation_status?: 'idle' | 'queued' | 'processing' | 'completed' | 'error'; - generation_progress?: number; - generation_error?: string; created_at: string; updated_at: string; modules?: Module[];