Fix match result showing under/over instead of actual fight winner

- Fixed bug in _update_bet_results where match.result was incorrectly set to UNDER/OVER when selected_result was UNDER/OVER
- Now properly looks for actual fight winner (WIN1, DRAW, WIN2, etc.) from winning outcomes or match outcomes
- Added print functionality to fixture details page with options to:
  - Print all matches or last N matches
  - Include/exclude completed or pending matches
- Added print-specific CSS for clean printouts
parent 80831a5b
...@@ -3744,22 +3744,40 @@ class GamesThread(ThreadedComponent): ...@@ -3744,22 +3744,40 @@ class GamesThread(ThreadedComponent):
logger.info(f"DEBUG _update_bet_results: Using pre-filtered winning outcomes: {winning_outcome_names}") logger.info(f"DEBUG _update_bet_results: Using pre-filtered winning outcomes: {winning_outcome_names}")
# Set the main result # Set the main result
# If selected_result is UNDER/OVER, use the first winning outcome as the main result # The match.result should always contain the actual fight winner (WIN1, DRAW, WIN2, etc.)
# (the actual fight winner like WIN1, X, WIN2) # not UNDER/OVER which is stored separately in under_over_result
if selected_result in ['UNDER', 'OVER'] and extraction_winning_outcome_names: if selected_result in ['UNDER', 'OVER']:
# Find the first non-UNDER/OVER winning outcome as the main result # selected_result is UNDER/OVER, we need to find the actual fight winner
main_result = None main_result = None
for outcome in extraction_winning_outcome_names:
if outcome not in ['UNDER', 'OVER']: # First, try to find a non-UNDER/OVER outcome from extraction winning outcomes
main_result = outcome if extraction_winning_outcome_names:
break for outcome in extraction_winning_outcome_names:
if outcome not in ['UNDER', 'OVER']:
main_result = outcome
logger.info(f"DEBUG _update_bet_results: Found fight winner '{main_result}' from extraction_winning_outcome_names")
break
# If not found in winning outcomes, look in match outcomes
if not main_result:
# Get all match outcomes and find a fight winner (non-UNDER/OVER outcome)
match_outcomes = session.query(MatchOutcomeModel).filter(
MatchOutcomeModel.match_id == match_id
).all()
for outcome in match_outcomes:
if outcome.column_name not in ['UNDER', 'OVER']:
main_result = outcome.column_name
logger.info(f"DEBUG _update_bet_results: Found fight winner '{main_result}' from match outcomes")
break
# Set the result
if main_result: if main_result:
match.result = main_result match.result = main_result
logger.info(f"DEBUG _update_bet_results: selected_result is UNDER/OVER, set match.result to '{main_result}' from winning outcomes") logger.info(f"DEBUG _update_bet_results: selected_result is UNDER/OVER, set match.result to fight winner '{main_result}'")
else: else:
# If no non-UNDER/OVER outcome found, use selected_result # Ultimate fallback - use selected_result but log warning
match.result = selected_result match.result = selected_result
logger.info(f"DEBUG _update_bet_results: No non-UNDER/OVER winning outcome found, set match.result to '{selected_result}'") logger.warning(f"DEBUG _update_bet_results: Could not find fight winner, using selected_result '{selected_result}' as fallback")
else: else:
match.result = selected_result match.result = selected_result
logger.info(f"DEBUG _update_bet_results: Set match.result to '{selected_result}'") logger.info(f"DEBUG _update_bet_results: Set match.result to '{selected_result}'")
......
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