12 Commits

Author SHA1 Message Date
afa666d2fd fix: scraper fix, add club info 2025-06-20 03:50:07 +02:00
b0ea0a836b scraper fix attempt 2025-06-20 01:19:48 +02:00
327aabde78 fix for goals 2025-06-16 23:21:34 +02:00
7ed241bc00 deleting some sections 2025-06-16 23:07:40 +02:00
ac2335a3bc one more 2025-06-16 23:00:38 +02:00
45dfd38f9a one fix for club stats 2025-06-16 22:57:19 +02:00
04b12d4657 fix: readd missing imports and funcs II 2025-06-15 04:59:37 +02:00
687bdedf88 fix: readd missing import 2025-06-15 04:52:37 +02:00
323a8b4973 Merge branch 'routes_using_api' 2025-06-15 04:50:27 +02:00
fc5acd28f7 Revert "chore: prepare for rescraping"
This reverts commit fce1b69893.
this time it works
2025-06-13 12:32:38 +02:00
19e100b4b2 fix 2025-06-13 12:15:04 +02:00
fcf11d4a0d Revert "chore: prepare for rescraping"
This reverts commit fce1b69893.
2025-06-13 12:12:10 +02:00
6 changed files with 17 additions and 15 deletions

View File

@@ -192,10 +192,7 @@ class scraper:
else:
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
safe_traverse(stats, ["596", "value"], default=None)
# print("todo :)")
self.db.simple_insert_one("sportowcy_w_meczach",
id_zawodnika = id_zawodnika,
@@ -257,7 +254,7 @@ class scraper:
wygrana = {"Z": 1, "R": 0, "P": -1}.get(safe_traverse(match, ["winLoseShort"], default=""), 0),
wynik = safe_traverse(match, ["rating"], default=0) or 0,
klub_id = klub_zawodnika
)
)
# TODO: Zaktualizuj statystyki sportowca

View File

@@ -18,7 +18,7 @@ scr = None
def setup():
# sanity check: make sure config is set
# required to make `flask --app lewy run --debug` work
global config, app_host, app_port, scrape
global config, app_host, app_port, scr
try:
if not config['general']:
lewy_globals.setConfig(lewy_globals.configfile)

View File

@@ -58,7 +58,7 @@ def __czy_x_istnieje(typ, **id):
return False
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):
return __czy_x_istnieje("kluby", id_klubu=id_klubu)
@@ -98,7 +98,7 @@ def stats():
return 200, "ok", data_to_send
# 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.
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
# 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.
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)
# 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"}
# Gdy sportowiec istnieje, wypisz jego statystyki.
@@ -306,4 +306,4 @@ def lookup(data, request):
return clubs(r = request)
case _:
increment_bad_requests()
return not_implemented(data)
return not_implemented(data)

View File

@@ -1,7 +1,7 @@
from datetime import datetime
from flask_sqlalchemy import SQLAlchemy
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 typing import List
import time

View File

@@ -8,6 +8,9 @@ def get_lewy_stats():
stats = player_stats(id_zawodnika=1)[2][0]
polska = robert_stats(id_klubu="polska")[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 {
'all_time_stats': {
'goals': stats["goals"], # 589+85
@@ -15,9 +18,9 @@ def get_lewy_stats():
'matches': stats["unique_items"] # 791+158
},
'club_stats': {
'goals': barcelona["goals"], # 589
'assists': barcelona["assists"], # 154
'matches': barcelona["unique_items"] # 791 # to trochę na wyrost, bo w części meczy był kontuzjowany
'goals': barcelona["goals"] + borussia["goals"] + bayern["goals"]+ und["goals"], # 589
'assists': barcelona["assists"] + borussia["assists"] + bayern["assists"]+ und["assists"], # 154
'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': {
'goals': polska["goals"], # 85
@@ -73,7 +76,7 @@ def mecze():
except:
selected_date = 2025
#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)
return render_template('matches.html', matches=matches, selected_date=selected_date)

View File

@@ -55,6 +55,7 @@
<p>Występy</p>
</div>
</section>
<!--
<section class="section-stats">
<h2>(!) Puchary międzynarodowe</h2>
<div class="stats">
@@ -89,6 +90,7 @@
</div>
</div>
</section>
-->
<section class="section-stats">
<h2>Kartki</h2>
<div class="stats">