fix: load previous state with correct team

This commit is contained in:
julius 2025-03-22 20:52:27 +01:00
parent 0397725bda
commit 8bc38a10a4
Signed by: julius
GPG Key ID: C80A63E6A5FD7092
2 changed files with 31 additions and 16 deletions

View File

@ -90,14 +90,16 @@ def submit_mvps(
raise wrong_user_id_exception
@api_router.get("/mvps", tags=["analysis"])
@api_router.get("/mvps/{team_id}", tags=["analysis"])
def get_mvps(
team_id: int,
user: Annotated[Player, Depends(get_current_active_user)],
):
with Session(engine) as session:
subquery = (
select(R.user, func.max(R.time).label("latest"))
.where(R.user == user.id)
.where(R.team == team_id)
.group_by(R.user)
.subquery()
)
@ -135,12 +137,15 @@ def submit_chemistry(
raise wrong_user_id_exception
@api_router.get("/chemistry", tags=["analysis"])
def get_chemistry(user: Annotated[Player, Depends(get_current_active_user)]):
@api_router.get("/chemistry/{team_id}", tags=["analysis"])
def get_chemistry(
team_id: int, user: Annotated[Player, Depends(get_current_active_user)]
):
with Session(engine) as session:
subquery = (
select(C.user, func.max(C.time).label("latest"))
.where(C.user == user.id)
.where(C.team == team_id)
.group_by(C.user)
.subquery()
)

View File

@ -96,16 +96,20 @@ function ChemistryDnD({ user, teams, players }: PlayerInfoProps) {
}
async function handleGet() {
const chemistry = (await apiAuth("chemistry", null, "GET")) as Chemistry;
setPlayersLeft(filterSort(otherPlayers, chemistry.hate));
setPlayersMiddle(
otherPlayers.filter(
(player) =>
!chemistry.hate.includes(player.id) &&
!chemistry.love.includes(player.id)
)
);
setPlayersRight(filterSort(otherPlayers, chemistry.love));
const data = await apiAuth(`chemistry/${teams.activeTeam}`, null, "GET");
if (data.detail) alert(data.detail);
else {
const chemistry = data as Chemistry;
setPlayersLeft(filterSort(otherPlayers, chemistry.hate));
setPlayersMiddle(
otherPlayers.filter(
(player) =>
!chemistry.hate.includes(player.id) &&
!chemistry.love.includes(player.id)
)
);
setPlayersRight(filterSort(otherPlayers, chemistry.love));
}
}
return (
@ -201,9 +205,15 @@ function MVPDnD({ user, teams, players }: PlayerInfoProps) {
}
async function handleGet() {
const mvps = (await apiAuth("mvps", null, "GET")) as MVPRanking;
setRankedPlayers(filterSort(players, mvps.mvps));
setAvailablePlayers(players.filter((user) => !mvps.mvps.includes(user.id)));
const data = await apiAuth(`mvps/${teams.activeTeam}`, null, "GET");
if (data.detail) alert(data.detail);
else {
const mvps = data as MVPRanking;
setRankedPlayers(filterSort(players, mvps.mvps));
setAvailablePlayers(
players.filter((user) => !mvps.mvps.includes(user.id))
);
}
}
return (