Spaces:
Running
Running
fix: 淘汰赛赛程注入真实日期,修复'即将开赛'回退到小组赛
Browse files- services/api/main.py +26 -4
services/api/main.py
CHANGED
|
@@ -805,7 +805,18 @@ def full_schedule():
|
|
| 805 |
ON p.home_team=m.home_team AND p.away_team=m.away_team AND p.model_run_id=?
|
| 806 |
LEFT JOIN teams th ON th.name=m.home_team
|
| 807 |
WHERE m.stage='group' ORDER BY m.date,m.id""", (rid,)).fetchall()
|
| 808 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 809 |
kmap = _kickoff_map()
|
| 810 |
out = []
|
| 811 |
for r in gs:
|
|
@@ -854,13 +865,24 @@ def full_schedule():
|
|
| 854 |
"exp_home": s["exp_home"], "exp_away": s["exp_away"],
|
| 855 |
"top_scores": s["top_scores"], "over25": s["over25"], "btts": s["btts"],
|
| 856 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 857 |
out.append({
|
| 858 |
-
"date":
|
| 859 |
"city": None, "country": None, "neutral": 1,
|
| 860 |
"stage": stage, "stage_label": STAGE_LABEL.get(stage, stage),
|
| 861 |
"match_id": mid,
|
| 862 |
-
"home_score":
|
| 863 |
-
"group_label": None, "kickoff":
|
| 864 |
**pred_data,
|
| 865 |
})
|
| 866 |
|
|
|
|
| 805 |
ON p.home_team=m.home_team AND p.away_team=m.away_team AND p.model_run_id=?
|
| 806 |
LEFT JOIN teams th ON th.name=m.home_team
|
| 807 |
WHERE m.stage='group' ORDER BY m.date,m.id""", (rid,)).fetchall()
|
| 808 |
+
# Round-of-32 fixtures with real dates/scores. The 16 chronologically
|
| 809 |
+
# first knockout games are the R32; later rounds are excluded so a
|
| 810 |
+
# mis-resolved third-place slot can't borrow a later round's date.
|
| 811 |
+
ko_rows = conn.execute(
|
| 812 |
+
"""SELECT date,home_team,away_team,home_score,away_score
|
| 813 |
+
FROM matches WHERE stage='knockout'
|
| 814 |
+
ORDER BY date, id LIMIT 16""").fetchall()
|
| 815 |
+
|
| 816 |
+
# lookup: "{home}__{away}" -> real R32 date/score, so resolved R32 slots can
|
| 817 |
+
# be placed on the calendar (else the dashboard's "即将开赛" section has no
|
| 818 |
+
# dated knockout match and falls back to the last group matchday).
|
| 819 |
+
ko_actual = {f"{r['home_team']}__{r['away_team']}": dict(r) for r in ko_rows}
|
| 820 |
kmap = _kickoff_map()
|
| 821 |
out = []
|
| 822 |
for r in gs:
|
|
|
|
| 865 |
"exp_home": s["exp_home"], "exp_away": s["exp_away"],
|
| 866 |
"top_scores": s["top_scores"], "over25": s["over25"], "btts": s["btts"],
|
| 867 |
}
|
| 868 |
+
# Once both teams are decided, attach the real fixture date/kickoff/score.
|
| 869 |
+
kdate = khs = kas = kickoff = None
|
| 870 |
+
if ta and tb:
|
| 871 |
+
act = ko_actual.get(f"{ta}__{tb}")
|
| 872 |
+
if act:
|
| 873 |
+
kdate, khs, kas = act["date"], act["home_score"], act["away_score"]
|
| 874 |
+
else:
|
| 875 |
+
act = ko_actual.get(f"{tb}__{ta}") # stored other way round
|
| 876 |
+
if act:
|
| 877 |
+
kdate, khs, kas = act["date"], act["away_score"], act["home_score"]
|
| 878 |
+
kickoff = kmap.get(f"{ta}__{tb}") or kmap.get(f"{tb}__{ta}")
|
| 879 |
out.append({
|
| 880 |
+
"date": kdate, "home_team": ta, "away_team": tb,
|
| 881 |
"city": None, "country": None, "neutral": 1,
|
| 882 |
"stage": stage, "stage_label": STAGE_LABEL.get(stage, stage),
|
| 883 |
"match_id": mid,
|
| 884 |
+
"home_score": khs, "away_score": kas,
|
| 885 |
+
"group_label": None, "kickoff": kickoff,
|
| 886 |
**pred_data,
|
| 887 |
})
|
| 888 |
|