-- 获取任务382的完整信息

-- 1. 查看完整的错误信息（不截断）
SELECT 
    id,
    user_id,
    lover_id,
    status,
    error_msg,
    created_at,
    updated_at,
    attempts
FROM nf_generation_tasks
WHERE id = 382\G

-- 2. 查看完整的payload（格式化显示）
SELECT JSON_PRETTY(payload) as payload_detail
FROM nf_generation_tasks
WHERE id = 382\G

-- 3. 检查用户资源
SELECT 
    u.id,
    u.mobile,
    u.nickname,
    u.video_gen_remaining,
    u.image_gen_remaining,
    u.voice_call_minutes_remaining,
    u.status
FROM nf_user u
WHERE u.id = 85\G

-- 4. 检查恋人信息
SELECT 
    l.id,
    l.user_id,
    l.name,
    l.gender,
    l.image_url,
    l.status,
    l.created_at
FROM nf_lover l
WHERE l.id = 64\G

-- 5. 检查歌曲信息
SELECT 
    sl.id,
    sl.title,
    sl.artist,
    sl.gender,
    sl.duration_sec,
    sl.audio_url,
    sl.audio_hash,
    sl.status,
    sl.deletetime
FROM nf_song_library sl
WHERE sl.id = 9\G

-- 6. 查看分段视频状态（如果有）
SELECT 
    sv.id as segment_video_id,
    sv.segment_id,
    sv.status,
    sv.error_msg,
    sv.dashscope_task_id,
    sv.video_url,
    sv.created_at,
    sv.updated_at,
    ss.segment_index,
    ss.duration_ms,
    ss.audio_url
FROM nf_song_segment_video sv
LEFT JOIN nf_song_segment ss ON sv.segment_id = ss.id
WHERE sv.song_id = 9
AND sv.image_hash = '81c04a23a800bb03ff62f0e26d0bf38de13bcbe91c08c46e461d6714a9645288'
ORDER BY ss.segment_index\G

-- 7. 查看EMO检测缓存（如果有）
SELECT 
    ed.id,
    ed.lover_id,
    ed.image_url,
    ed.image_hash,
    ed.ratio,
    ed.check_pass,
    ed.face_bbox,
    ed.ext_bbox,
    ed.error_msg,
    ed.created_at
FROM nf_emo_detect_cache ed
WHERE ed.lover_id = 64
AND ed.image_hash = '81c04a23a800bb03ff62f0e26d0bf38de13bcbe91c08c46e461d6714a9645288'
ORDER BY ed.created_at DESC
LIMIT 1\G

-- 8. 查看聊天消息（了解上下文）
SELECT 
    cm.id,
    cm.role,
    cm.content_type,
    cm.content,
    cm.extra,
    cm.created_at
FROM nf_chat_message cm
WHERE cm.id IN (810, 811)
ORDER BY cm.id\G

-- 9. 查看同一用户的其他任务
SELECT 
    id,
    task_type,
    status,
    error_msg,
    created_at
FROM nf_generation_tasks
WHERE user_id = 85
ORDER BY created_at DESC
LIMIT 10\G

-- 10. 查看同一恋人的其他任务
SELECT 
    id,
    user_id,
    task_type,
    status,
    error_msg,
    created_at
FROM nf_generation_tasks
WHERE lover_id = 64
ORDER BY created_at DESC
LIMIT 10\G
