Compare commits
2 Commits
d1f5f8f3f4
...
frontend-f
| Author | SHA1 | Date | |
|---|---|---|---|
| 8fb2a22c2a | |||
| f96a3ed1f1 |
@@ -95,12 +95,11 @@ 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: str | 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 = []
|
||||||
@@ -110,14 +109,9 @@ def get_matches(r = None, id_zawodnika: str | None = None, rok: int | None = Non
|
|||||||
# 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().get_sportsman_matches(year=rok)
|
mecze = getDb().simple_select_all("mecze")
|
||||||
|
|
||||||
# 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.
|
||||||
@@ -126,7 +120,7 @@ def get_matches(r = None, id_zawodnika: str | None = None, rok: int | None = Non
|
|||||||
|
|
||||||
# Gdy sportowiec istnieje, wypisz jego mecze.
|
# Gdy sportowiec istnieje, wypisz jego mecze.
|
||||||
else:
|
else:
|
||||||
mecze = getDb().get_sportsman_matches(id_zawodnika=id_zawodnika, year=rok)
|
mecze = getDb().get_sportsman_matches(id_zawodnika=id_zawodnika)
|
||||||
|
|
||||||
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, extract
|
from sqlalchemy import ForeignKey, select, insert, update
|
||||||
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,9 +517,8 @@ 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", year = None):
|
def get_sportsman_matches(self, id_zawodnika = None, zewnetrzne_id_zawodnika = None, order = "DESC"):
|
||||||
|
|
||||||
# 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)
|
||||||
|
|
||||||
@@ -532,25 +531,17 @@ 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
|
||||||
)
|
)
|
||||||
|
|
||||||
if year is not None:
|
# print(f"get_sportsman_matches: {query}")
|
||||||
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,13 +60,9 @@ 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, rok=selected_date)
|
status, msg, matches = get_matches(None, id_zawodnika=1)
|
||||||
|
|
||||||
return render_template('matches.html', matches=matches, selected_date=selected_date)
|
return render_template('matches.html', matches=matches, selected_date=selected_date)
|
||||||
|
|
||||||
|
|||||||
@@ -386,34 +386,6 @@ 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -906,4 +878,32 @@ select
|
|||||||
background-color: var(--barca-blue);
|
background-color: var(--barca-blue);
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
border: 2px solid white;
|
border: 2px solid white;
|
||||||
|
}
|
||||||
|
@media (max-width: 600px){
|
||||||
|
.sectionmatches
|
||||||
|
{
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
|
.sectionmatches 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="stat-box">
|
<div class="stat-box">
|
||||||
<h3>{{ player.assists}}</h3>
|
<h3>{{ player.matches}}</h3>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
<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>
|
||||||
|
|
||||||
@@ -48,6 +49,7 @@
|
|||||||
<td>{{ match.minutes }}</td>
|
<td>{{ match.minutes }}</td>
|
||||||
-->
|
-->
|
||||||
</tr>
|
</tr>
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
Reference in New Issue
Block a user