This commit is contained in:
zkldi
2021-09-07 09:25:26 +01:00
parent 451238d324
commit 5e964ea157
6 changed files with 23 additions and 14 deletions
+1 -1
View File
@@ -74,7 +74,7 @@
"resolve": "1.12.0",
"resolve-url-loader": "3.1.0",
"socicon": "3.0.5",
"tachi-common": "0.1.42"
"tachi-common": "0.2.4"
},
"devDependencies": {
"@types/humanize-duration": "3.25.1",
+4 -4
View File
@@ -76,7 +76,7 @@ specifiers:
serve: 11.2.0
socicon: 3.0.5
style-loader: 1.0.0
tachi-common: 0.1.42
tachi-common: 0.2.4
terser-webpack-plugin: 1.4.1
ts-pnp: 1.1.4
typescript: 4.3.5
@@ -140,7 +140,7 @@ dependencies:
resolve: 1.12.0
resolve-url-loader: 3.1.0
socicon: 3.0.5
tachi-common: 0.1.42_typescript@4.3.5
tachi-common: 0.2.4_typescript@4.3.5
devDependencies:
'@types/humanize-duration': 3.25.1
@@ -11760,8 +11760,8 @@ packages:
strip-ansi: 6.0.0
dev: true
/tachi-common/0.1.42_typescript@4.3.5:
resolution: {integrity: sha512-3rNfFXObf9eO6Rf/B/IncQ441bQXfCZvmZgsWYXyVl8GjtGH03/wblGp2stCHRXnau+l5n/k7SUn1G9hw516WA==}
/tachi-common/0.2.4_typescript@4.3.5:
resolution: {integrity: sha512-5Q6c0qGhQyPKKiCg+BvuYbt9k5q/B1c3aBNR3KaX+aEKSQ8ZbuYTcKPKnQlDccjDfcGNj2OAmELx3oHz4UJdGA==}
dependencies:
monk: 7.3.4
tap: 15.0.9_typescript@4.3.5
@@ -96,7 +96,7 @@ function GameStatContainer({ ugs, reqUser }: { ugs: UGSWithRankingData } & Props
header={FormatGame(ugs.game, ugs.playtype)}
>
<UGPTRatingsTable ugs={ugs} />
<LazyRankingData ranking={ugs.__rankingData.ranking} outOf={ugs.__rankingData.outOf} />
<RankingData game={ugs.game} playtype={ugs.playtype} rankingData={ugs.__rankingData} />
</Card>
);
}
@@ -17,6 +17,8 @@ import { GamePT } from "types/react";
import { APIFetchV1 } from "util/api";
import SelectButton from "components/util/SelectButton";
import Icon from "components/util/Icon";
import { useSessionRatingAlg } from "components/util/useScoreRatingAlg";
import { NumericSOV } from "util/sorts";
export default function SessionsPage({
reqUser,
@@ -38,6 +40,8 @@ export default function SessionsPage({
const baseUrl = `/users/${reqUser.id}/games/${game}/${playtype}/sessions`;
const rating = useSessionRatingAlg(game, playtype);
const { isLoading, error, data } = useQuery<SessionDataset, UnsuccessfulAPIResponse>(
`${baseUrl}/${sessionSet}`,
async () => {
@@ -47,12 +51,14 @@ export default function SessionsPage({
throw res;
}
return res.body.map((e, i) => ({
...e,
__related: {
index: i,
},
}));
return res.body
.sort(NumericSOV(x => x.calculatedData[rating] ?? 0, true))
.map((e, i) => ({
...e,
__related: {
index: i,
},
}));
}
);
+1 -1
View File
@@ -86,7 +86,7 @@ export interface SpecificSessionReturns<I extends IDStrings = IDStrings> {
}
export type UGSWithRankingData<I extends IDStrings = IDStrings> = UserGameStats<I> & {
__rankingData: { outOf: number; ranking: number };
__rankingData: Record<UGSRatingsLookup[I], { outOf: number; ranking: number }>;
};
export interface SongChartsSearch<I extends IDStrings = IDStrings> {
+4 -1
View File
@@ -16,7 +16,10 @@ export function PropSort(...props: string[]) {
* Sorts On Value numerically.
* @returns A sorting function
*/
export function NumericSOV<T>(getValueFn: (data: T) => number) {
export function NumericSOV<T>(getValueFn: (data: T) => number, reverse = false) {
if (reverse) {
return (a: T, b: T) => getValueFn(b) - getValueFn(a);
}
return (a: T, b: T) => getValueFn(a) - getValueFn(b);
}