Fix match result display: use display_result field to show actual fight winner...

Fix match result display: use display_result field to show actual fight winner instead of UNDER/OVER
parent 8b194f1a
...@@ -1267,7 +1267,8 @@ ...@@ -1267,7 +1267,8 @@
const matchNumber = match.match_number || match.id || 'N/A'; const matchNumber = match.match_number || match.id || 'N/A';
const fighter1 = match.fighter1_township || match.fighter1 || 'Fighter 1'; const fighter1 = match.fighter1_township || match.fighter1 || 'Fighter 1';
const fighter2 = match.fighter2_township || match.fighter2 || 'Fighter 2'; const fighter2 = match.fighter2_township || match.fighter2 || 'Fighter 2';
const result = match.result || 'Unknown'; // Use display_result if available (handles UNDER/OVER cases), otherwise fall back to result
const result = match.display_result || match.result || 'Unknown';
const underOver = match.under_over_result || ''; const underOver = match.under_over_result || '';
const resultText = underOver ? `${result} (${underOver})` : result; const resultText = underOver ? `${result} (${underOver})` : result;
......
...@@ -1337,7 +1337,8 @@ ...@@ -1337,7 +1337,8 @@
const matchNumber = match.match_number || match.id || 'N/A'; const matchNumber = match.match_number || match.id || 'N/A';
const fighter1 = match.fighter1_township || match.fighter1 || 'Fighter 1'; const fighter1 = match.fighter1_township || match.fighter1 || 'Fighter 1';
const fighter2 = match.fighter2_township || match.fighter2 || 'Fighter 2'; const fighter2 = match.fighter2_township || match.fighter2 || 'Fighter 2';
const result = match.result || 'Unknown'; // Use display_result if available (handles UNDER/OVER cases), otherwise fall back to result
const result = match.display_result || match.result || 'Unknown';
const underOver = match.under_over_result || ''; const underOver = match.under_over_result || '';
const resultText = underOver ? `${result} (${underOver})` : result; const resultText = underOver ? `${result} (${underOver})` : result;
......
...@@ -10922,6 +10922,23 @@ def get_overlay_completed_matches(): ...@@ -10922,6 +10922,23 @@ def get_overlay_completed_matches():
matches_data = [] matches_data = []
for match in completed_matches: for match in completed_matches:
# Parse winning_outcomes JSON if available
winning_outcomes = []
if match.winning_outcomes:
try:
winning_outcomes = json.loads(match.winning_outcomes) if isinstance(match.winning_outcomes, str) else match.winning_outcomes
except (json.JSONDecodeError, TypeError):
winning_outcomes = []
# Determine the main result to display
# If result is UNDER/OVER, use the first non-UNDER/OVER winning outcome as the main result
display_result = match.result
if match.result in ['UNDER', 'OVER'] and winning_outcomes:
for outcome in winning_outcomes:
if outcome not in ['UNDER', 'OVER']:
display_result = outcome
break
match_data = { match_data = {
'id': match.id, 'id': match.id,
'match_number': match.match_number, 'match_number': match.match_number,
...@@ -10929,7 +10946,9 @@ def get_overlay_completed_matches(): ...@@ -10929,7 +10946,9 @@ def get_overlay_completed_matches():
'fighter2_township': match.fighter2_township, 'fighter2_township': match.fighter2_township,
'venue_kampala_township': match.venue_kampala_township, 'venue_kampala_township': match.venue_kampala_township,
'result': match.result, 'result': match.result,
'display_result': display_result, # The result to display (actual fight winner)
'under_over_result': match.under_over_result, 'under_over_result': match.under_over_result,
'winning_outcomes': winning_outcomes,
'end_time': match.end_time.isoformat() if match.end_time else None 'end_time': match.end_time.isoformat() if match.end_time else None
} }
matches_data.append(match_data) matches_data.append(match_data)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment