Compare commits
4 Commits
frontend-f
...
7b457475b4
| Author | SHA1 | Date | |
|---|---|---|---|
| 7b457475b4 | |||
| d1f5f8f3f4 | |||
| 56e68ed751 | |||
| 416b2ccfe0 |
@@ -95,11 +95,12 @@ 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):
|
def get_matches(r = None, id_zawodnika: str | None = None, rok: int | None = None):
|
||||||
"""
|
"""
|
||||||
Zwraca mecze.
|
Zwraca mecze.
|
||||||
Przykład wywołania:
|
Przykład wywołania:
|
||||||
get_matches(r, id_zawodnika=1), tożsame z GET /api/v1/matches?id_zawodnika=1
|
get_matches(r, id_zawodnika=1), tożsame z GET /api/v1/matches?id_zawodnika=1
|
||||||
|
get_matches(r, rok=2024), tożsame z GET /api/v1/matches?rok=2024
|
||||||
get_matches(r), tożsame z GET /api/v1/matches
|
get_matches(r), tożsame z GET /api/v1/matches
|
||||||
"""
|
"""
|
||||||
response_json = []
|
response_json = []
|
||||||
@@ -109,9 +110,14 @@ def get_matches(r = None, id_zawodnika: str | None = None):
|
|||||||
# Gdy nie podano id wprost, sprawdź, czy podano je przez parametr.
|
# Gdy nie podano id wprost, sprawdź, czy podano je przez parametr.
|
||||||
id_zawodnika = r.args.get('id_zawodnika', -1)
|
id_zawodnika = r.args.get('id_zawodnika', -1)
|
||||||
|
|
||||||
|
if rok is None:
|
||||||
|
# Gdy nie podano roku wprost, sprawdź, czy podano je przez parametr.
|
||||||
|
# Jeśli nie, przyjmij None (2025).
|
||||||
|
rok = r.args.get('rok', None)
|
||||||
|
|
||||||
# Sprawdź, czy podano jakiekolwiek ID sportowca. Jeżeli nie, wypisz wszystkie mecze.
|
# Sprawdź, czy podano jakiekolwiek ID sportowca. Jeżeli nie, wypisz wszystkie mecze.
|
||||||
if id_zawodnika == -1:
|
if id_zawodnika == -1:
|
||||||
mecze = getDb().simple_select_all("mecze")
|
mecze = getDb().get_sportsman_matches(year=rok)
|
||||||
|
|
||||||
# Sprawdź, czy sportowiec o podanym (lub niepodanym) id istnieje.
|
# Sprawdź, czy sportowiec o podanym (lub niepodanym) id istnieje.
|
||||||
# Jeśli nie istnieje, wypisz wszystkie mecze.
|
# Jeśli nie istnieje, wypisz wszystkie mecze.
|
||||||
@@ -120,7 +126,7 @@ def get_matches(r = None, id_zawodnika: str | None = None):
|
|||||||
|
|
||||||
# Gdy sportowiec istnieje, wypisz jego mecze.
|
# Gdy sportowiec istnieje, wypisz jego mecze.
|
||||||
else:
|
else:
|
||||||
mecze = getDb().get_sportsman_matches(id_zawodnika=id_zawodnika)
|
mecze = getDb().get_sportsman_matches(id_zawodnika=id_zawodnika, year=rok)
|
||||||
|
|
||||||
for mecz in mecze:
|
for mecz in mecze:
|
||||||
response_json.append(mecz.jsonify())
|
response_json.append(mecz.jsonify())
|
||||||
|
|||||||
@@ -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
|
from sqlalchemy import ForeignKey, select, insert, update, extract
|
||||||
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
|
||||||
@@ -517,8 +517,9 @@ class baza():
|
|||||||
return query.all()
|
return query.all()
|
||||||
|
|
||||||
@exit_gracefully
|
@exit_gracefully
|
||||||
def get_sportsman_matches(self, id_zawodnika = None, zewnetrzne_id_zawodnika = None, order = "DESC"):
|
def get_sportsman_matches(self, id_zawodnika = None, zewnetrzne_id_zawodnika = None, order = "DESC", year = None):
|
||||||
|
|
||||||
|
# Spróbuj otrzymać id zawodnika z zewnętrznego id.
|
||||||
if zewnetrzne_id_zawodnika is not None:
|
if zewnetrzne_id_zawodnika is not None:
|
||||||
id_zawodnika = self.get_id_zawodnika_by_zewnetrzne_id(zewnetrzne_id_zawodnika)
|
id_zawodnika = self.get_id_zawodnika_by_zewnetrzne_id(zewnetrzne_id_zawodnika)
|
||||||
|
|
||||||
@@ -531,17 +532,25 @@ class baza():
|
|||||||
Mecze
|
Mecze
|
||||||
).join(
|
).join(
|
||||||
SportowcyWMeczach, Mecze.zewnetrzne_id_meczu == SportowcyWMeczach.zewnetrzne_id_meczu
|
SportowcyWMeczach, Mecze.zewnetrzne_id_meczu == SportowcyWMeczach.zewnetrzne_id_meczu
|
||||||
).join(
|
)
|
||||||
|
|
||||||
|
if id_zawodnika is not None:
|
||||||
|
query = query.join(
|
||||||
Sportowcy, SportowcyWMeczach.id_zawodnika == Sportowcy.id_zawodnika
|
Sportowcy, SportowcyWMeczach.id_zawodnika == Sportowcy.id_zawodnika
|
||||||
).filter(
|
).filter(
|
||||||
Sportowcy.id_zawodnika == id_zawodnika
|
Sportowcy.id_zawodnika == id_zawodnika
|
||||||
)
|
)
|
||||||
|
|
||||||
# print(f"get_sportsman_matches: {query}")
|
if year is not None:
|
||||||
|
query = query.filter(
|
||||||
|
extract("year", Mecze.data) == year
|
||||||
|
)
|
||||||
|
|
||||||
if order.lower() == "desc":
|
if order.lower() == "desc":
|
||||||
query = query.order_by(Mecze.data.desc())
|
query = query.order_by(Mecze.data.desc())
|
||||||
|
|
||||||
|
# print(f"get_sportsman_matches: {query}")
|
||||||
|
|
||||||
return query.all()
|
return query.all()
|
||||||
|
|
||||||
@exit_gracefully
|
@exit_gracefully
|
||||||
|
|||||||
@@ -60,9 +60,13 @@ def index():
|
|||||||
def mecze():
|
def mecze():
|
||||||
# Możesz dostarczyć szczegóły dotyczące meczów
|
# Możesz dostarczyć szczegóły dotyczące meczów
|
||||||
selected_date = request.args.get("date", '2025')
|
selected_date = request.args.get("date", '2025')
|
||||||
|
try:
|
||||||
|
selected_date = int(selected_date)
|
||||||
|
except:
|
||||||
|
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)
|
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)
|
||||||
|
|
||||||
|
|||||||
@@ -386,6 +386,34 @@ header button {
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@media (max-width: 600px){
|
||||||
|
.section__matches
|
||||||
|
{
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
|
.section__matches th{
|
||||||
|
padding: 3px;
|
||||||
|
}
|
||||||
|
.club-stats-grid
|
||||||
|
{
|
||||||
|
grid-template-columns: 1fr 1fr !important;
|
||||||
|
}
|
||||||
|
.club-stats-grid .stat-box
|
||||||
|
{
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.section-stats-center .section-stats .stats
|
||||||
|
{
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.section-stats-center .section-stats .stats .stat-box
|
||||||
|
{
|
||||||
|
width: 100%;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,6 @@
|
|||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for match in matches %}
|
{% for match in matches %}
|
||||||
{% if match.data[:4] == selected_date %}
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ match.data }}</td>
|
<td>{{ match.data }}</td>
|
||||||
|
|
||||||
@@ -49,7 +48,6 @@
|
|||||||
<td>{{ match.minutes }}</td>
|
<td>{{ match.minutes }}</td>
|
||||||
-->
|
-->
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
Reference in New Issue
Block a user