Fix indentation error in fixtures API logging

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