mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-04 04:48:15 +03:00
fix: postgresfixes 3
This commit is contained in:
+2
-8
@@ -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<SessionDataset, UnsuccessfulAPIResponse>(
|
||||
`${baseUrl}/${sessionSet}`,
|
||||
async () => {
|
||||
const res = await APIFetchV1<
|
||||
({ __scoreInfo: Array<SessionScoreInfo> } & SessionDocument)[]
|
||||
>(`${baseUrl}/${sessionSet}`);
|
||||
const res = await APIFetchV1<SessionDocument[]>(`${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 },
|
||||
}));
|
||||
},
|
||||
);
|
||||
|
||||
@@ -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<SessionScoreInfo> };
|
||||
/** Present when API attaches per-score PB deltas (list views omit this). */
|
||||
__related: { index: integer; scoreInfo?: Array<SessionScoreInfo> };
|
||||
} & SessionDocument)[];
|
||||
|
||||
export default function GenericSessionTable({
|
||||
|
||||
@@ -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
|
||||
|
||||
+6
-22
@@ -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<SessionDocument>,
|
||||
): Promise<Array<{ __scoreInfo: Array<SessionScoreInfo> } & 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);
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user