Compare commits
12 Commits
routes_usi
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| afa666d2fd | |||
| b0ea0a836b | |||
| 327aabde78 | |||
| 7ed241bc00 | |||
| ac2335a3bc | |||
| 45dfd38f9a | |||
| 04b12d4657 | |||
| 687bdedf88 | |||
| 323a8b4973 | |||
| fc5acd28f7 | |||
| 19e100b4b2 | |||
| fcf11d4a0d |
@@ -192,10 +192,7 @@ class scraper:
|
|||||||
else:
|
else:
|
||||||
klub_zawodnika = home_club_id
|
klub_zawodnika = home_club_id
|
||||||
|
|
||||||
#klub_z = getDb().simple_select_all("kluby", id_klubu=klub_zawodnika)
|
|
||||||
|
|
||||||
if stats != False: # gdy sportowiec był aktywny w meczu
|
if stats != False: # gdy sportowiec był aktywny w meczu
|
||||||
safe_traverse(stats, ["596", "value"], default=None)
|
|
||||||
# print("todo :)")
|
# print("todo :)")
|
||||||
self.db.simple_insert_one("sportowcy_w_meczach",
|
self.db.simple_insert_one("sportowcy_w_meczach",
|
||||||
id_zawodnika = id_zawodnika,
|
id_zawodnika = id_zawodnika,
|
||||||
@@ -257,7 +254,7 @@ class scraper:
|
|||||||
wygrana = {"Z": 1, "R": 0, "P": -1}.get(safe_traverse(match, ["winLoseShort"], default=""), 0),
|
wygrana = {"Z": 1, "R": 0, "P": -1}.get(safe_traverse(match, ["winLoseShort"], default=""), 0),
|
||||||
wynik = safe_traverse(match, ["rating"], default=0) or 0,
|
wynik = safe_traverse(match, ["rating"], default=0) or 0,
|
||||||
klub_id = klub_zawodnika
|
klub_id = klub_zawodnika
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO: Zaktualizuj statystyki sportowca
|
# TODO: Zaktualizuj statystyki sportowca
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ scr = None
|
|||||||
def setup():
|
def setup():
|
||||||
# sanity check: make sure config is set
|
# sanity check: make sure config is set
|
||||||
# required to make `flask --app lewy run --debug` work
|
# required to make `flask --app lewy run --debug` work
|
||||||
global config, app_host, app_port, scrape
|
global config, app_host, app_port, scr
|
||||||
try:
|
try:
|
||||||
if not config['general']:
|
if not config['general']:
|
||||||
lewy_globals.setConfig(lewy_globals.configfile)
|
lewy_globals.setConfig(lewy_globals.configfile)
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ def __czy_x_istnieje(typ, **id):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def czy_sportowiec_istnieje(id_zawodnika: str):
|
def czy_sportowiec_istnieje(id_zawodnika: str):
|
||||||
return __czy_x_istnieje("sportowcy", id_zawodnika=int(id_zawodnika))
|
return __czy_x_istnieje("sportowcy", id_zawodnika=id_zawodnika)
|
||||||
|
|
||||||
def czy_klub_istnieje(id_klubu: str):
|
def czy_klub_istnieje(id_klubu: str):
|
||||||
return __czy_x_istnieje("kluby", id_klubu=id_klubu)
|
return __czy_x_istnieje("kluby", id_klubu=id_klubu)
|
||||||
@@ -98,7 +98,7 @@ def stats():
|
|||||||
return 200, "ok", data_to_send
|
return 200, "ok", data_to_send
|
||||||
|
|
||||||
# GET /api/v1/matches
|
# GET /api/v1/matches
|
||||||
def get_matches(r = None, id_zawodnika: str | None = None, rok: int | None = None):
|
def get_matches(r = None, id_zawodnika: int | None = None, rok: int | None = None):
|
||||||
"""
|
"""
|
||||||
Zwraca mecze.
|
Zwraca mecze.
|
||||||
Przykład wywołania:
|
Przykład wywołania:
|
||||||
@@ -137,7 +137,7 @@ def get_matches(r = None, id_zawodnika: str | None = None, rok: int | None = Non
|
|||||||
return 200, "ok", response_json
|
return 200, "ok", response_json
|
||||||
|
|
||||||
# GET /api/v1/player_stats
|
# GET /api/v1/player_stats
|
||||||
def player_stats(r = None, id_zawodnika: str | None = None):
|
def player_stats(r = None, id_zawodnika: int | None = None):
|
||||||
"""
|
"""
|
||||||
Zwraca statystyki gracza.
|
Zwraca statystyki gracza.
|
||||||
Przykład wywołania:
|
Przykład wywołania:
|
||||||
@@ -151,7 +151,7 @@ def player_stats(r = None, id_zawodnika: str | None = None):
|
|||||||
id_zawodnika = r.args.get('id_zawodnika', 0)
|
id_zawodnika = r.args.get('id_zawodnika', 0)
|
||||||
|
|
||||||
# Sprawdź, czy sportowiec o podanym (lub niepodanym) id istnieje.
|
# Sprawdź, czy sportowiec o podanym (lub niepodanym) id istnieje.
|
||||||
elif not czy_sportowiec_istnieje(id_zawodnika=id_zawodnika):
|
if not czy_sportowiec_istnieje(id_zawodnika=id_zawodnika):
|
||||||
return 404, "error", {"error_msg": "This sportsman has not been found in the database. Try: id_zawodnika=1"}
|
return 404, "error", {"error_msg": "This sportsman has not been found in the database. Try: id_zawodnika=1"}
|
||||||
|
|
||||||
# Gdy sportowiec istnieje, wypisz jego statystyki.
|
# Gdy sportowiec istnieje, wypisz jego statystyki.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from flask_sqlalchemy import SQLAlchemy
|
from flask_sqlalchemy import SQLAlchemy
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from sqlalchemy import ForeignKey, select, insert, update, extract, func, case, literal_column
|
from sqlalchemy import ForeignKey, select, insert, update, extract, func, case
|
||||||
from sqlalchemy.orm import Mapped, mapped_column, DeclarativeBase, Session, relationship
|
from sqlalchemy.orm import Mapped, mapped_column, DeclarativeBase, Session, relationship
|
||||||
from typing import List
|
from typing import List
|
||||||
import time
|
import time
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ def get_lewy_stats():
|
|||||||
stats = player_stats(id_zawodnika=1)[2][0]
|
stats = player_stats(id_zawodnika=1)[2][0]
|
||||||
polska = robert_stats(id_klubu="polska")[2][0]
|
polska = robert_stats(id_klubu="polska")[2][0]
|
||||||
barcelona = robert_stats(id_klubu="barcelona")[2][0]
|
barcelona = robert_stats(id_klubu="barcelona")[2][0]
|
||||||
|
borussia = robert_stats(id_klubu="dortmund")[2][0]
|
||||||
|
bayern = robert_stats(id_klubu="bayern")[2][0]
|
||||||
|
und = robert_stats(id_klubu="undefined")[2][0]
|
||||||
return {
|
return {
|
||||||
'all_time_stats': {
|
'all_time_stats': {
|
||||||
'goals': stats["goals"], # 589+85
|
'goals': stats["goals"], # 589+85
|
||||||
@@ -15,9 +18,9 @@ def get_lewy_stats():
|
|||||||
'matches': stats["unique_items"] # 791+158
|
'matches': stats["unique_items"] # 791+158
|
||||||
},
|
},
|
||||||
'club_stats': {
|
'club_stats': {
|
||||||
'goals': barcelona["goals"], # 589
|
'goals': barcelona["goals"] + borussia["goals"] + bayern["goals"]+ und["goals"], # 589
|
||||||
'assists': barcelona["assists"], # 154
|
'assists': barcelona["assists"] + borussia["assists"] + bayern["assists"]+ und["assists"], # 154
|
||||||
'matches': barcelona["unique_items"] # 791 # to trochę na wyrost, bo w części meczy był kontuzjowany
|
'matches': barcelona["unique_items"] + borussia["unique_items"] + bayern["unique_items"]+ und["unique_items"] # 791 # to trochę na wyrost, bo w części meczy był kontuzjowany
|
||||||
},
|
},
|
||||||
'nation_stats': {
|
'nation_stats': {
|
||||||
'goals': polska["goals"], # 85
|
'goals': polska["goals"], # 85
|
||||||
@@ -73,7 +76,7 @@ def mecze():
|
|||||||
except:
|
except:
|
||||||
selected_date = 2025
|
selected_date = 2025
|
||||||
#with open("static/lewandowski_matches.json", "r") as file:
|
#with open("static/lewandowski_matches.json", "r") as file:
|
||||||
# data = json.load(file)
|
# data = json.load(file)
|
||||||
status, msg, matches = get_matches(None, id_zawodnika=1, rok=selected_date)
|
status, msg, matches = get_matches(None, id_zawodnika=1, rok=selected_date)
|
||||||
|
|
||||||
return render_template('matches.html', matches=matches, selected_date=selected_date)
|
return render_template('matches.html', matches=matches, selected_date=selected_date)
|
||||||
|
|||||||
@@ -55,6 +55,7 @@
|
|||||||
<p>Występy</p>
|
<p>Występy</p>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
<!--
|
||||||
<section class="section-stats">
|
<section class="section-stats">
|
||||||
<h2>(!) Puchary międzynarodowe</h2>
|
<h2>(!) Puchary międzynarodowe</h2>
|
||||||
<div class="stats">
|
<div class="stats">
|
||||||
@@ -89,6 +90,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
-->
|
||||||
<section class="section-stats">
|
<section class="section-stats">
|
||||||
<h2>Kartki</h2>
|
<h2>Kartki</h2>
|
||||||
<div class="stats">
|
<div class="stats">
|
||||||
|
|||||||
Reference in New Issue
Block a user