토너먼트 대진 추가
This commit is contained in:
1 parent
59db1c4e9a
commit
6815540ae6
6 files changed
+161
-50
No files matched your search
+17
-4
@@ -202,10 +202,23 @@ async def settle_matches() -> None:
|
||||
if due or recheck_ids:
|
||||
results = await fetch_results()
|
||||
# 정방향/역방향 키 모두 등록 — 소스의 홈/원정 순서가 우리와 달라도 매칭.
|
||||
# 라운드(round_label)를 키에 포함해 같은 두 팀의 조별리그·토너먼트 경기를 구분.
|
||||
# round_label 없는 소스(openfootball) 대비 라운드 무시 키도 함께 등록(폴백).
|
||||
by_pair: dict[tuple, tuple[int, int]] = {}
|
||||
for r in results:
|
||||
by_pair[(r["teamA"], r["teamB"])] = (r["scoreA"], r["scoreB"])
|
||||
by_pair[(r["teamB"], r["teamA"])] = (r["scoreB"], r["scoreA"]) # 뒤집어 저장
|
||||
rl = r.get("roundLabel", "")
|
||||
a2, b2, sa, sb = r["teamA"], r["teamB"], r["scoreA"], r["scoreB"]
|
||||
for key in ((rl, a2, b2), (a2, b2)):
|
||||
by_pair[key] = (sa, sb)
|
||||
for key in ((rl, b2, a2), (b2, a2)): # 뒤집어 저장
|
||||
by_pair[key] = (sb, sa)
|
||||
|
||||
def _lookup(m: Match) -> tuple[int, int] | None:
|
||||
# 라운드까지 일치하는 결과 우선, 없으면 팀쌍만으로 폴백.
|
||||
return by_pair.get((m.round_label, m.team_a_code, m.team_b_code)) or by_pair.get(
|
||||
(m.team_a_code, m.team_b_code)
|
||||
)
|
||||
|
||||
settled = corrected = 0
|
||||
async with SessionLocal() as db:
|
||||
# 1) 신규 정산 — 미정산 경기에 FINISHED 스코어 반영
|
||||
@@ -213,7 +226,7 @@ async def settle_matches() -> None:
|
||||
m = await db.get(Match, mid)
|
||||
if m is None or m.result_outcome is not None:
|
||||
continue
|
||||
sc = by_pair.get((m.team_a_code, m.team_b_code))
|
||||
sc = _lookup(m)
|
||||
if not sc:
|
||||
continue
|
||||
await apply_result(db, m, sc[0], sc[1]) # 우리 팀A/팀B 기준으로 채점+집계+commit
|
||||
@@ -224,7 +237,7 @@ async def settle_matches() -> None:
|
||||
m = await db.get(Match, mid)
|
||||
if m is None or m.result_outcome is None:
|
||||
continue
|
||||
sc = by_pair.get((m.team_a_code, m.team_b_code))
|
||||
sc = _lookup(m)
|
||||
if not sc:
|
||||
continue # 소스에 아직 없으면 기존값 유지
|
||||
if (m.result_score_a, m.result_score_b) == (sc[0], sc[1]):
|
||||
|
||||
Reference in new issue
Block a user