Files
ai-showcase-platform/scripts/complete-virtual-apps-setup.sql
2025-09-18 18:34:31 +08:00

108 lines
2.5 KiB
SQL

-- =====================================================
-- 完整的虛擬應用設置腳本
-- =====================================================
-- 1. 查看現有團隊
SELECT '=== 現有團隊 ===' as info;
SELECT id, name, department FROM teams WHERE is_active = TRUE;
-- 2. 查看現有應用
SELECT '=== 現有應用 ===' as info;
SELECT id, name, type FROM apps WHERE is_active = TRUE LIMIT 5;
-- 3. 創建虛擬應用記錄
SELECT '=== 創建虛擬應用 ===' as info;
-- 為團隊 aaa 創建虛擬應用
INSERT IGNORE INTO apps (
id,
name,
description,
creator_id,
category,
type,
app_url,
icon,
icon_color,
likes_count,
views_count,
rating,
is_active,
created_at,
updated_at
) VALUES (
'team_t1757702332911zcl6iafq1',
'[團隊評分] aaa',
'團隊 aaa 的評分記錄 - 用於存儲團隊評分數據',
'00000000-0000-0000-0000-000000000000',
'team_scoring',
'team',
NULL,
'Users',
'from-gray-500 to-gray-600',
0,
0,
0.00,
TRUE,
NOW(),
NOW()
);
-- 4. 驗證虛擬應用創建
SELECT '=== 虛擬應用創建結果 ===' as info;
SELECT id, name, type, category, is_active FROM apps WHERE id LIKE 'team_%';
-- 5. 測試插入團隊評分記錄
SELECT '=== 測試團隊評分插入 ===' as info;
-- 插入測試評分記錄
INSERT INTO app_judge_scores (
id,
judge_id,
app_id,
innovation_score,
technical_score,
usability_score,
presentation_score,
impact_score,
total_score,
comments,
submitted_at
) VALUES (
UUID(),
'fed0a353-8ffe-11f0-bb38-4adff2d0e33e', -- 評審ID
'team_t1757702332911zcl6iafq1', -- 虛擬應用ID
8, -- innovation_score
7, -- technical_score
9, -- usability_score
8, -- presentation_score
7, -- impact_score
7.8, -- total_score (平均分)
'測試團隊評分記錄',
NOW()
);
-- 6. 驗證評分記錄插入
SELECT '=== 評分記錄插入結果 ===' as info;
SELECT
ajs.id,
ajs.judge_id,
ajs.app_id,
ajs.innovation_score,
ajs.technical_score,
ajs.usability_score,
ajs.presentation_score,
ajs.impact_score,
ajs.total_score,
ajs.comments,
ajs.submitted_at,
a.name as app_name
FROM app_judge_scores ajs
LEFT JOIN apps a ON ajs.app_id = a.id
WHERE ajs.app_id LIKE 'team_%'
ORDER BY ajs.submitted_at DESC;
-- 7. 清理測試數據(可選)
-- DELETE FROM app_judge_scores WHERE app_id LIKE 'team_%';
-- DELETE FROM apps WHERE id LIKE 'team_%';