Fix indentation error in fixtures API logging

parent b5bb674b
...@@ -10778,67 +10778,67 @@ def get_overlay_fixtures(): ...@@ -10778,67 +10778,67 @@ def get_overlay_fixtures():
all_matches = [] all_matches = []
if yesterday_incomplete_matches: if yesterday_incomplete_matches:
logger.info(f"[FIXTURES API] Found {len(yesterday_incomplete_matches)} incomplete matches from yesterday - including them") logger.info(f"[FIXTURES API] Found {len(yesterday_incomplete_matches)} incomplete matches from yesterday - including them")
all_matches.extend(yesterday_incomplete_matches) all_matches.extend(yesterday_incomplete_matches)
all_matches.extend(today_matches) all_matches.extend(today_matches)
# Limit to 5 matches total # Limit to 5 matches total
display_matches = all_matches[:5] display_matches = all_matches[:5]
logger.info(f"[FIXTURES API] Processing {len(display_matches)} matches for display") logger.info(f"[FIXTURES API] Processing {len(display_matches)} matches for display")
fixtures_data = [] fixtures_data = []
for i, match in enumerate(display_matches): for i, match in enumerate(display_matches):
try: try:
logger.info(f"[FIXTURES API] Processing match {i+1}: id={match.id}, match_number={match.match_number}") logger.info(f"[FIXTURES API] Processing match {i+1}: id={match.id}, match_number={match.match_number}")
# Get outcomes from MatchOutcomeModel # Get outcomes from MatchOutcomeModel
outcomes = session.query(MatchOutcomeModel).filter_by(match_id=match.id).all() outcomes = session.query(MatchOutcomeModel).filter_by(match_id=match.id).all()
logger.info(f"[FIXTURES API] Found {len(outcomes)} outcomes for match {match.id}") logger.info(f"[FIXTURES API] Found {len(outcomes)} outcomes for match {match.id}")
# Format outcomes as array expected by template # Format outcomes as array expected by template
outcomes_array = [] outcomes_array = []
for outcome in outcomes: for outcome in outcomes:
outcomes_array.append({ outcomes_array.append({
'outcome_name': outcome.column_name, 'outcome_name': outcome.column_name,
'outcome_value': outcome.float_value 'outcome_value': outcome.float_value
}) })
# If no outcomes in database, create default ones from match odds # If no outcomes in database, create default ones from match odds
if not outcomes_array: if not outcomes_array:
outcomes_array = [ outcomes_array = [
{'outcome_name': 'WIN1', 'outcome_value': float(match.odds_fighter1) if match.odds_fighter1 else 1.0}, {'outcome_name': 'WIN1', 'outcome_value': float(match.odds_fighter1) if match.odds_fighter1 else 1.0},
{'outcome_name': 'X', 'outcome_value': float(match.odds_draw) if match.odds_draw else 3.0}, {'outcome_name': 'X', 'outcome_value': float(match.odds_draw) if match.odds_draw else 3.0},
{'outcome_name': 'WIN2', 'outcome_value': float(match.odds_fighter2) if match.odds_fighter2 else 1.0}, {'outcome_name': 'WIN2', 'outcome_value': float(match.odds_fighter2) if match.odds_fighter2 else 1.0},
{'outcome_name': 'UNDER', 'outcome_value': 1.75}, {'outcome_name': 'UNDER', 'outcome_value': 1.75},
{'outcome_name': 'OVER', 'outcome_value': 2.05} {'outcome_name': 'OVER', 'outcome_value': 2.05}
] ]
match_data = { match_data = {
'id': match.id, 'id': match.id,
'match_number': match.match_number, 'match_number': match.match_number,
'fixture_id': match.fixture_id, 'fixture_id': match.fixture_id,
'fighter1_township': match.fighter1_township, 'fighter1_township': match.fighter1_township,
'fighter2_township': match.fighter2_township, 'fighter2_township': match.fighter2_township,
'venue_kampala_township': match.venue_kampala_township, 'venue_kampala_township': match.venue_kampala_township,
'status': match.status, 'status': match.status,
'start_time': match.start_time.isoformat() if match.start_time else None, 'start_time': match.start_time.isoformat() if match.start_time else None,
'result': match.result, 'result': match.result,
'outcomes': outcomes_array, # Array format expected by template 'outcomes': outcomes_array, # Array format expected by template
# Keep odds for backwards compatibility # Keep odds for backwards compatibility
'odds': { 'odds': {
'fighter1': float(match.odds_fighter1) if match.odds_fighter1 else 1.0, 'fighter1': float(match.odds_fighter1) if match.odds_fighter1 else 1.0,
'fighter2': float(match.odds_fighter2) if match.odds_fighter2 else 1.0, 'fighter2': float(match.odds_fighter2) if match.odds_fighter2 else 1.0,
'draw': float(match.odds_draw) if match.odds_draw else 3.0 'draw': float(match.odds_draw) if match.odds_draw else 3.0
}
} }
fixtures_data.append(match_data) }
logger.info(f"[FIXTURES API] Successfully processed match {match.id}") fixtures_data.append(match_data)
except Exception as match_error: logger.info(f"[FIXTURES API] Successfully processed match {match.id}")
logger.error(f"[FIXTURES API] Error processing match {match.id}: {match_error}") except Exception as match_error:
continue logger.error(f"[FIXTURES API] Error processing match {match.id}: {match_error}")
continue
logger.info(f"[FIXTURES API] Returning {len(fixtures_data)} matches")
return jsonify(fixtures_data) logger.info(f"[FIXTURES API] Returning {len(fixtures_data)} matches")
return jsonify(fixtures_data)
finally: finally:
session.close() session.close()
......
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