diff --git a/main.py b/main.py index 82cc4d3..d522ff7 100644 --- a/main.py +++ b/main.py @@ -893,12 +893,22 @@ async def get_programs_scores(data: dict): placeholders = ','.join(['?' for _ in sn_list]) cursor.execute( f""" - SELECT program_sn, judge_id, - COALESCE(admin_total_score, - COALESCE(content_score,0) + COALESCE(stage_score,0) + - COALESCE(art_score,0) + COALESCE(overall_score,0) - ) AS final_total - FROM scores WHERE program_sn IN ({placeholders}) + SELECT + program_sn, + judge_id, + CASE + WHEN (admin_total_score IS NOT NULL OR + content_score IS NOT NULL OR + stage_score IS NOT NULL OR + art_score IS NOT NULL OR + overall_score IS NOT NULL) + THEN COALESCE(admin_total_score, + COALESCE(content_score,0) + COALESCE(stage_score,0) + + COALESCE(art_score,0) + COALESCE(overall_score,0)) + ELSE NULL + END AS final_total + FROM scores + WHERE program_sn IN ({placeholders}) """, sn_list, ) @@ -1937,7 +1947,8 @@ HTML_TEMPLATE = """ const progScores = scoresMap[prog.sn]; if(progScores && progScores[judge.id] !== undefined && progScores[judge.id] !== null) score = progScores[judge.id]; - html += ``; + let scoreValue = (score !== null && score !== undefined) ? score : ''; + html += ``; } html += ``; }