добавил автоматическую загрузку тренеров в состав матча из кнопки Загрузка данных с сайта
This commit is contained in:
18
app.py
18
app.py
@@ -646,22 +646,28 @@ def load_match_data(request: Request, session_token: str):
|
|||||||
match_external_id = session_row[8]
|
match_external_id = session_row[8]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
run_parser_game(str(match_external_id))
|
|
||||||
|
|
||||||
# сброс ручного состава и тренеров, чтобы подтянулись свежие данные парсера
|
|
||||||
from db import get_connection
|
from db import get_connection
|
||||||
|
|
||||||
|
# Сначала очищаем ручные данные матча,
|
||||||
|
# чтобы парсер потом записал свежие составы и тренеров
|
||||||
conn = get_connection()
|
conn = get_connection()
|
||||||
try:
|
try:
|
||||||
with conn.cursor() as cur:
|
with conn.cursor() as cur:
|
||||||
cur.execute(
|
cur.execute(
|
||||||
"DELETE FROM match_lineup_players WHERE match_id = %s", (match_id,)
|
"DELETE FROM match_lineup_players WHERE match_id = %s",
|
||||||
|
(match_id,),
|
||||||
|
)
|
||||||
|
cur.execute(
|
||||||
|
"DELETE FROM match_coaches WHERE match_id = %s",
|
||||||
|
(match_id,),
|
||||||
)
|
)
|
||||||
cur.execute("DELETE FROM match_coaches WHERE match_id = %s", (match_id,))
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
finally:
|
finally:
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
# Потом загружаем свежие данные с сайта
|
||||||
|
run_parser_game(str(match_external_id))
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error_text = str(e) or "Ошибка загрузки данных с сайта"
|
error_text = str(e) or "Ошибка загрузки данных с сайта"
|
||||||
|
|
||||||
@@ -692,7 +698,7 @@ def load_match_data(request: Request, session_token: str):
|
|||||||
return RedirectResponse(
|
return RedirectResponse(
|
||||||
url=f"/admin/session/{session_token}?tab=game",
|
url=f"/admin/session/{session_token}?tab=game",
|
||||||
status_code=303,
|
status_code=303,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.post("/admin/session/{session_token}/close")
|
@app.post("/admin/session/{session_token}/close")
|
||||||
|
|||||||
Reference in New Issue
Block a user