修正評審評分機制問題
This commit is contained in:
@@ -93,6 +93,8 @@ export async function GET(request: NextRequest) {
|
||||
|
||||
// 構建每日使用數據
|
||||
const dailyUsageData = []
|
||||
console.log('🔍 開始構建每日使用數據...')
|
||||
|
||||
for (let i = 6; i >= 0; i--) {
|
||||
const date = new Date(Date.now() - i * 24 * 60 * 60 * 1000)
|
||||
const dateStr = date.toISOString().split('T')[0]
|
||||
@@ -111,7 +113,7 @@ export async function GET(request: NextRequest) {
|
||||
const memoryPeak = Math.min(85, 25 + dailyUsers * 0.7 + dailySessions * 0.04)
|
||||
const requests = dailySessions + dailyActivity
|
||||
|
||||
dailyUsageData.push({
|
||||
const dayData = {
|
||||
date: `${date.getMonth() + 1}/${date.getDate()}`,
|
||||
fullDate: date.toLocaleDateString("zh-TW"),
|
||||
dayName: dayName,
|
||||
@@ -121,8 +123,13 @@ export async function GET(request: NextRequest) {
|
||||
avgCpu: Math.round(avgCpu),
|
||||
memoryPeak: Math.round(memoryPeak),
|
||||
requests: requests
|
||||
})
|
||||
}
|
||||
|
||||
dailyUsageData.push(dayData)
|
||||
console.log(`📊 ${dateStr}:`, dayData)
|
||||
}
|
||||
|
||||
console.log('✅ 每日使用數據構建完成:', dailyUsageData)
|
||||
|
||||
// 獲取應用類別分布
|
||||
const categoryDataResult = await db.query(`
|
||||
@@ -146,6 +153,8 @@ export async function GET(request: NextRequest) {
|
||||
apps: item.app_count
|
||||
}
|
||||
})
|
||||
|
||||
console.log('📊 類別數據:', categoryData)
|
||||
|
||||
// 獲取熱門應用排行
|
||||
const topAppsResult = await db.query(`
|
||||
|
76
app/api/admin/debug-competition-data/route.ts
Normal file
76
app/api/admin/debug-competition-data/route.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
// =====================================================
|
||||
// 調試競賽數據 API
|
||||
// =====================================================
|
||||
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { DatabaseServiceBase } from '@/lib/services/database-service';
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const competitionId = searchParams.get('competitionId') || '07e2303e-9647-11f0-b5d9-6e36c63cdb98';
|
||||
|
||||
console.log('🔍 開始調試競賽數據...');
|
||||
console.log('競賽ID:', competitionId);
|
||||
|
||||
// 1. 檢查競賽是否存在
|
||||
const competitionCheck = await DatabaseServiceBase.safeQuery(
|
||||
'SELECT * FROM competitions WHERE id = ?',
|
||||
[competitionId]
|
||||
);
|
||||
|
||||
console.log('📊 競賽檢查結果:', competitionCheck);
|
||||
|
||||
// 2. 檢查競賽應用關聯
|
||||
const competitionAppsCheck = await DatabaseServiceBase.safeQuery(
|
||||
'SELECT * FROM competition_apps WHERE competition_id = ?',
|
||||
[competitionId]
|
||||
);
|
||||
|
||||
console.log('📊 競賽應用關聯檢查結果:', competitionAppsCheck);
|
||||
|
||||
// 3. 檢查所有應用程式
|
||||
const allAppsCheck = await DatabaseServiceBase.safeQuery(
|
||||
'SELECT id, name, is_active FROM apps WHERE is_active = 1 LIMIT 10',
|
||||
[]
|
||||
);
|
||||
|
||||
console.log('📊 所有應用程式檢查結果:', allAppsCheck);
|
||||
|
||||
// 4. 檢查競賽規則
|
||||
const competitionRulesCheck = await DatabaseServiceBase.safeQuery(
|
||||
'SELECT * FROM competition_rules WHERE competition_id = ?',
|
||||
[competitionId]
|
||||
);
|
||||
|
||||
console.log('📊 競賽規則檢查結果:', competitionRulesCheck);
|
||||
|
||||
// 5. 檢查評審
|
||||
const judgesCheck = await DatabaseServiceBase.safeQuery(
|
||||
'SELECT id, name, title, department FROM judges WHERE is_active = 1 LIMIT 5',
|
||||
[]
|
||||
);
|
||||
|
||||
console.log('📊 評審檢查結果:', judgesCheck);
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: '調試數據獲取成功',
|
||||
data: {
|
||||
competition: competitionCheck,
|
||||
competitionApps: competitionAppsCheck,
|
||||
allApps: allAppsCheck,
|
||||
competitionRules: competitionRulesCheck,
|
||||
judges: judgesCheck
|
||||
}
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ 調試競賽數據失敗:', error);
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
message: '調試競賽數據失敗',
|
||||
error: error instanceof Error ? error.message : '未知錯誤'
|
||||
}, { status: 500 });
|
||||
}
|
||||
}
|
@@ -8,7 +8,12 @@ export async function GET(request: NextRequest) {
|
||||
const judgeId = searchParams.get('judgeId');
|
||||
const competitionId = searchParams.get('competitionId');
|
||||
|
||||
console.log('🔍 評審任務API - 接收請求');
|
||||
console.log('judgeId:', judgeId);
|
||||
console.log('competitionId:', competitionId);
|
||||
|
||||
if (!judgeId) {
|
||||
console.log('❌ 缺少評審ID');
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
message: '缺少評審ID',
|
||||
@@ -17,8 +22,12 @@ export async function GET(request: NextRequest) {
|
||||
}
|
||||
|
||||
// 獲取評審信息
|
||||
console.log('🔍 開始獲取評審信息...');
|
||||
const judge = await JudgeService.getJudgeById(judgeId);
|
||||
console.log('📊 評審信息查詢結果:', judge);
|
||||
|
||||
if (!judge) {
|
||||
console.log('❌ 評審不存在');
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
message: '評審不存在',
|
||||
@@ -27,17 +36,22 @@ export async function GET(request: NextRequest) {
|
||||
}
|
||||
|
||||
// 獲取評審的評分任務
|
||||
console.log('🔍 開始獲取評分任務...');
|
||||
let scoringTasks = [];
|
||||
|
||||
if (competitionId) {
|
||||
// 獲取特定競賽的評分任務
|
||||
console.log('📊 獲取特定競賽的評分任務');
|
||||
scoringTasks = await JudgeService.getJudgeScoringTasks(judgeId, competitionId);
|
||||
} else {
|
||||
// 獲取所有評分任務
|
||||
console.log('📊 獲取所有評分任務');
|
||||
scoringTasks = await JudgeService.getJudgeScoringTasks(judgeId);
|
||||
}
|
||||
|
||||
return NextResponse.json({
|
||||
console.log('📊 評分任務查詢結果:', scoringTasks);
|
||||
|
||||
const response = {
|
||||
success: true,
|
||||
message: '評分任務獲取成功',
|
||||
data: {
|
||||
@@ -46,14 +60,17 @@ export async function GET(request: NextRequest) {
|
||||
name: judge.name,
|
||||
title: judge.title,
|
||||
department: judge.department,
|
||||
specialty: judge.specialty || '評審專家'
|
||||
specialty: '評審專家'
|
||||
},
|
||||
tasks: scoringTasks
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
console.log('✅ API回應:', response);
|
||||
return NextResponse.json(response);
|
||||
|
||||
} catch (error) {
|
||||
console.error('獲取評分任務失敗:', error);
|
||||
console.error('❌ 獲取評分任務失敗:', error);
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
message: '獲取評分任務失敗',
|
||||
|
Reference in New Issue
Block a user