From ffe807362fcd49bda24194ff0f592a649113ed6a Mon Sep 17 00:00:00 2001 From: zk Date: Mon, 18 May 2026 12:21:09 +0000 Subject: [PATCH] fix: postgresfixes 3 --- .../games/_game/_playtype/SessionsPage.tsx | 10 ++----- .../tables/sessions/GenericSessionTable.tsx | 3 +- typescript/server/.env | 2 +- .../games/_game/_playtype/sessions/router.ts | 28 ++++--------------- 4 files changed, 11 insertions(+), 32 deletions(-) diff --git a/typescript/client/src/app/pages/dashboard/users/games/_game/_playtype/SessionsPage.tsx b/typescript/client/src/app/pages/dashboard/users/games/_game/_playtype/SessionsPage.tsx index c1818b3a4..980318b72 100644 --- a/typescript/client/src/app/pages/dashboard/users/games/_game/_playtype/SessionsPage.tsx +++ b/typescript/client/src/app/pages/dashboard/users/games/_game/_playtype/SessionsPage.tsx @@ -19,7 +19,6 @@ import { GameToGameGroup, GetGameGroupConfig, type SessionDocument, - type SessionScoreInfo, type UnsuccessfulAPIResponse, type UserDocument, } from "tachi-common"; @@ -47,9 +46,7 @@ export default function SessionsPage({ reqUser, game }: UGPT) { const { data, error } = useQuery( `${baseUrl}/${sessionSet}`, async () => { - const res = await APIFetchV1< - ({ __scoreInfo: Array } & SessionDocument)[] - >(`${baseUrl}/${sessionSet}`); + const res = await APIFetchV1(`${baseUrl}/${sessionSet}`); if (!res.success) { throw res; @@ -63,10 +60,7 @@ export default function SessionsPage({ reqUser, game }: UGPT) { ) .map((e, i) => ({ ...e, - __related: { - index: i, - scoreInfo: e.__scoreInfo, - }, + __related: { index: i }, })); }, ); diff --git a/typescript/client/src/components/tables/sessions/GenericSessionTable.tsx b/typescript/client/src/components/tables/sessions/GenericSessionTable.tsx index b66911583..b7fcb2f4f 100644 --- a/typescript/client/src/components/tables/sessions/GenericSessionTable.tsx +++ b/typescript/client/src/components/tables/sessions/GenericSessionTable.tsx @@ -20,7 +20,8 @@ import SelectableRating from "../components/SelectableRating"; import TachiTable, { type Header, type ZTableTHProps } from "../components/TachiTable"; export type SessionDataset = ({ - __related: { index: integer; scoreInfo: Array }; + /** Present when API attaches per-score PB deltas (list views omit this). */ + __related: { index: integer; scoreInfo?: Array }; } & SessionDocument)[]; export default function GenericSessionTable({ diff --git a/typescript/server/.env b/typescript/server/.env index 2bb87dee0..e5199e557 100644 --- a/typescript/server/.env +++ b/typescript/server/.env @@ -4,7 +4,7 @@ PORT=8080 LOG_LEVEL="debug" MSGPACKR_NATIVE_ACCELERATION_DISABLED=true -POSTGRES_URL="postgresql://tachi:tachi@tachi-postgres/tachi_dev" +POSTGRES_URL="postgresql://tachi:tachi@tachi-postgres/tachi_kamai" MIGRATIONS_DIR="/tachi/db/migrations" REDIS_URL=tachi-redis diff --git a/typescript/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/sessions/router.ts b/typescript/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/sessions/router.ts index cdbe9196f..9e5fc3348 100644 --- a/typescript/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/sessions/router.ts +++ b/typescript/server/src/server/router/api/v1/users/_userID/games/_game/_playtype/sessions/router.ts @@ -18,22 +18,9 @@ import { type AnySessionRatingAlg, GetGameConfig, LEGACY_GameToGameGroupPT, - type SessionDocument, - type SessionScoreInfo, } from "tachi-common"; import { type Game } from "tachi-db"; -function attachSessionScoreInfo( - sessions: Array, -): Promise } & SessionDocument>> { - return Promise.all( - sessions.map(async (session) => ({ - ...session, - __scoreInfo: await GetSessionScoreInfo(session), - })), - ); -} - /** * Search a users sessions. * @@ -95,13 +82,12 @@ API_V1_ROUTER.add( const scoreMap = await GetScoreIdsGroupedBySessionId(rows.map((r) => r.id)); const sessions = rows.map((row) => ToSessionDocument(row, scoreMap.get(row.id) ?? [])); - const sessionsWithScoreInfo = await attachSessionScoreInfo(sessions); - sessionsWithScoreInfo.sort( + sessions.sort( (a, b) => (b.calculatedData[alg] ?? -Infinity) - (a.calculatedData[alg] ?? -Infinity), ); - return success(`Retrieved ${sessions.length} sessions.`, sessionsWithScoreInfo); + return success(`Retrieved ${sessions.length} sessions.`, sessions); }, ); @@ -127,11 +113,10 @@ API_V1_ROUTER.add( const scoreMap = await GetScoreIdsGroupedBySessionId(rows.map((r) => r.id)); const sessions = rows.map((row) => ToSessionDocument(row, scoreMap.get(row.id) ?? [])); - const sessionsWithScoreInfo = await attachSessionScoreInfo(sessions); - sessionsWithScoreInfo.sort((a, b) => b.timeEnded - a.timeEnded); + sessions.sort((a, b) => b.timeEnded - a.timeEnded); - return success(`Returned ${sessions.length} sessions.`, sessionsWithScoreInfo); + return success(`Returned ${sessions.length} sessions.`, sessions); }, ); @@ -157,11 +142,10 @@ API_V1_ROUTER.add( const scoreMap = await GetScoreIdsGroupedBySessionId(rows.map((r) => r.id)); const sessions = rows.map((row) => ToSessionDocument(row, scoreMap.get(row.id) ?? [])); - const sessionsWithScoreInfo = await attachSessionScoreInfo(sessions); - sessionsWithScoreInfo.sort((a, b) => b.timeEnded - a.timeEnded); + sessions.sort((a, b) => b.timeEnded - a.timeEnded); - return success(`Returned ${sessions.length} sessions.`, sessionsWithScoreInfo); + return success(`Returned ${sessions.length} sessions.`, sessions); }, );