Preparar repositorio para despliegue: código fuente limpio

This commit is contained in:
jlimolina 2026-01-23 02:00:40 +01:00
parent 866f5c432d
commit 3eca832c1a
76 changed files with 5434 additions and 3496 deletions

View file

@ -0,0 +1,2 @@
-- Add avatar_url column to users table if it doesn't exist
ALTER TABLE usuarios ADD COLUMN IF NOT EXISTS avatar_url TEXT;

View file

@ -0,0 +1,38 @@
-- Migration: Add pending feeds table for review workflow
-- This table stores discovered feeds that need manual review/approval
CREATE TABLE IF NOT EXISTS feeds_pending (
id SERIAL PRIMARY KEY,
fuente_url_id INTEGER REFERENCES fuentes_url(id) ON DELETE CASCADE,
feed_url TEXT NOT NULL UNIQUE,
feed_title VARCHAR(255),
feed_description TEXT,
feed_language CHAR(5),
feed_type VARCHAR(20),
entry_count INTEGER DEFAULT 0,
detected_country_id INTEGER REFERENCES paises(id),
suggested_categoria_id INTEGER REFERENCES categorias(id),
categoria_id INTEGER REFERENCES categorias(id),
pais_id INTEGER REFERENCES paises(id),
idioma CHAR(2),
discovered_at TIMESTAMP DEFAULT NOW(),
reviewed BOOLEAN DEFAULT FALSE,
approved BOOLEAN DEFAULT FALSE,
reviewed_at TIMESTAMP,
reviewed_by VARCHAR(100),
notes TEXT
);
CREATE INDEX IF NOT EXISTS idx_feeds_pending_reviewed ON feeds_pending(reviewed, approved);
CREATE INDEX IF NOT EXISTS idx_feeds_pending_fuente ON feeds_pending(fuente_url_id);
-- Add constraint to fuentes_url to require categoria_id or pais_id for processing
ALTER TABLE fuentes_url
ADD COLUMN IF NOT EXISTS require_review BOOLEAN DEFAULT TRUE,
ADD COLUMN IF NOT EXISTS auto_approve BOOLEAN DEFAULT FALSE;
COMMENT ON TABLE feeds_pending IS 'Feeds discovered but pending review/approval before being added to active feeds';
COMMENT ON COLUMN feeds_pending.detected_country_id IS 'Country detected automatically from feed language/domain';
COMMENT ON COLUMN feeds_pending.suggested_categoria_id IS 'Category suggested based on feed content/keywords';
COMMENT ON COLUMN fuentes_url.require_review IS 'If TRUE, feeds from this URL need manual approval';
COMMENT ON COLUMN fuentes_url.auto_approve IS 'If TRUE, feeds are automatically approved and activated';

View file

@ -0,0 +1,7 @@
-- Add fuente_url_id to feeds table for traceability
ALTER TABLE feeds
ADD COLUMN IF NOT EXISTS fuente_url_id INTEGER REFERENCES fuentes_url(id) ON DELETE SET NULL;
CREATE INDEX IF NOT EXISTS idx_feeds_fuente_url ON feeds(fuente_url_id);
COMMENT ON COLUMN feeds.fuente_url_id IS 'ID of the URL source that discovered this feed';

View file

@ -0,0 +1,90 @@
-- Script SQL para crear tablas de parrillas de noticias para videos
-- Tabla principal de parrillas/programaciones
CREATE TABLE IF NOT EXISTS video_parrillas (
id SERIAL PRIMARY KEY,
nombre VARCHAR(255) NOT NULL UNIQUE,
descripcion TEXT,
tipo_filtro VARCHAR(50) NOT NULL, -- 'pais', 'categoria', 'entidad', 'continente', 'custom'
-- Filtros
pais_id INTEGER REFERENCES paises(id),
categoria_id INTEGER REFERENCES categorias(id),
continente_id INTEGER REFERENCES continentes(id),
entidad_nombre VARCHAR(255), -- Para filtrar por persona/organización específica
entidad_tipo VARCHAR(50), -- 'persona', 'organizacion'
-- Configuración de generación
max_noticias INTEGER DEFAULT 5, -- Número máximo de noticias por video
duracion_maxima INTEGER DEFAULT 180, -- Duración máxima en segundos
idioma_voz VARCHAR(10) DEFAULT 'es', -- Idioma del TTS
voz_modelo VARCHAR(100), -- Modelo de voz específico a usar
-- Configuración de diseño
template VARCHAR(50) DEFAULT 'standard', -- 'standard', 'modern', 'minimal'
include_images BOOLEAN DEFAULT true,
include_subtitles BOOLEAN DEFAULT true,
-- Programación
frecuencia VARCHAR(20), -- 'daily', 'weekly', 'manual'
ultima_generacion TIMESTAMP,
proxima_generacion TIMESTAMP,
-- Estado
activo BOOLEAN DEFAULT true,
created_at TIMESTAMP DEFAULT NOW(),
updated_at TIMESTAMP DEFAULT NOW()
);
-- Tabla de videos generados
CREATE TABLE IF NOT EXISTS video_generados (
id SERIAL PRIMARY KEY,
parrilla_id INTEGER REFERENCES video_parrillas(id) ON DELETE CASCADE,
titulo VARCHAR(500) NOT NULL,
descripcion TEXT,
fecha_generacion TIMESTAMP DEFAULT NOW(),
-- Archivos
video_path VARCHAR(500),
audio_path VARCHAR(500),
subtitles_path VARCHAR(500),
thumbnail_path VARCHAR(500),
-- Metadata
duracion INTEGER, -- en segundos
num_noticias INTEGER,
noticias_ids TEXT[], -- Array de IDs de noticias incluidas
-- Estado de procesamiento
status VARCHAR(20) DEFAULT 'pending', -- 'pending', 'processing', 'completed', 'error'
error_message TEXT,
-- Estadísticas
views INTEGER DEFAULT 0,
created_at TIMESTAMP DEFAULT NOW()
);
-- Tabla de noticias en videos (relación muchos a muchos)
CREATE TABLE IF NOT EXISTS video_noticias (
id SERIAL PRIMARY KEY,
video_id INTEGER REFERENCES video_generados(id) ON DELETE CASCADE,
noticia_id VARCHAR(100) NOT NULL,
traduccion_id INTEGER REFERENCES traducciones(id),
orden INTEGER NOT NULL, -- Orden de aparición en el video
timestamp_inicio FLOAT, -- Segundo donde comienza esta noticia
timestamp_fin FLOAT, -- Segundo donde termina esta noticia
created_at TIMESTAMP DEFAULT NOW()
);
-- Índices para mejorar performance
CREATE INDEX IF NOT EXISTS idx_parrillas_tipo ON video_parrillas(tipo_filtro);
CREATE INDEX IF NOT EXISTS idx_parrillas_activo ON video_parrillas(activo);
CREATE INDEX IF NOT EXISTS idx_parrillas_proxima ON video_parrillas(proxima_generacion);
CREATE INDEX IF NOT EXISTS idx_videos_parrilla ON video_generados(parrilla_id);
CREATE INDEX IF NOT EXISTS idx_videos_status ON video_generados(status);
CREATE INDEX IF NOT EXISTS idx_videos_fecha ON video_generados(fecha_generacion DESC);
-- Comentarios para documentación
COMMENT ON TABLE video_parrillas IS 'Configuraciones de parrillas de noticias para generar videos automáticos';
COMMENT ON TABLE video_generados IS 'Videos generados a partir de parrillas de noticias';
COMMENT ON TABLE video_noticias IS 'Relación entre videos y las noticias que contienen';