From de90ada4c358f8941a28fb3b5a4cd31468ddfd3b Mon Sep 17 00:00:00 2001 From: beer-psi Date: Thu, 3 Oct 2024 02:12:49 +0000 Subject: [PATCH 1/5] fix(client): use the rating formatter specified in tachi-common for history graph --- .../_game/_playtype/GPTLeaderboardsPage.tsx | 6 +-- .../games/_game/_playtype/OverviewPage.tsx | 37 +++++++++++++++---- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/client/src/app/pages/dashboard/games/_game/_playtype/GPTLeaderboardsPage.tsx b/client/src/app/pages/dashboard/games/_game/_playtype/GPTLeaderboardsPage.tsx index 8a910a392..c49fbcdce 100644 --- a/client/src/app/pages/dashboard/games/_game/_playtype/GPTLeaderboardsPage.tsx +++ b/client/src/app/pages/dashboard/games/_game/_playtype/GPTLeaderboardsPage.tsx @@ -1,5 +1,5 @@ import { CreateUserMap } from "util/data"; -import { ToFixedFloor, UppercaseFirst } from "util/misc"; +import { FormatGPTProfileRating, ToFixedFloor, UppercaseFirst } from "util/misc"; import { NumericSOV, StrSOV } from "util/sorts"; import ClassBadge from "components/game/ClassBadge"; import ScoreLeaderboard from "components/game/ScoreLeaderboard"; @@ -142,9 +142,7 @@ function ProfileLeaderboard({ game, playtype }: GamePT) { ).map((e) => ( {r.ratings[e] - ? gptConfig.profileRatingAlgs[e].formatter - ? gptConfig.profileRatingAlgs[e].formatter!(r.ratings[e]!) - : ToFixedFloor(r.ratings[e]!, 2) + ? FormatGPTProfileRating(game, playtype, e, r.ratings[e]!) : "No Data."} ))} diff --git a/client/src/app/pages/dashboard/users/games/_game/_playtype/OverviewPage.tsx b/client/src/app/pages/dashboard/users/games/_game/_playtype/OverviewPage.tsx index fd1ad86ed..7a63b5538 100644 --- a/client/src/app/pages/dashboard/users/games/_game/_playtype/OverviewPage.tsx +++ b/client/src/app/pages/dashboard/users/games/_game/_playtype/OverviewPage.tsx @@ -1,5 +1,4 @@ -import { ClumpActivity } from "util/activity"; -import { ToFixedFloor, UppercaseFirst } from "util/misc"; +import { FormatGPTProfileRating, UppercaseFirst } from "util/misc"; import { FormatDate, MillisToSince } from "util/time"; import TimelineChart from "components/charts/TimelineChart"; import useSetSubheader from "components/layout/header/useSetSubheader"; @@ -17,7 +16,14 @@ import SelectButton from "components/util/SelectButton"; import { useProfileRatingAlg } from "components/util/useScoreRatingAlg"; import { DateTime } from "luxon"; import React, { useMemo, useState } from "react"; -import { FormatGame, GetGameConfig, GetGamePTConfig, UserGameStats } from "tachi-common"; +import { + FormatGame, + Game, + GetGameConfig, + GetGamePTConfig, + Playtype, + UserGameStats, +} from "tachi-common"; import { UGPTHistory } from "types/api-returns"; import { GamePT, SetState, UGPT } from "types/react"; import FormSelect from "react-bootstrap/FormSelect"; @@ -110,7 +116,13 @@ function UserHistory({ const currentPropValue = useMemo(() => { if (mode === "rating" && rating) { - return data[0].ratings[rating] ? ToFixedFloor(data[0].ratings[rating]!, 2) : "N/A"; + const ratingValue = data[0].ratings[rating]; + + if (!ratingValue) { + return "N/A"; + } + + return FormatGPTProfileRating(game, playtype, rating, ratingValue); } else if (mode === "ranking") { return ( <> @@ -228,7 +240,7 @@ function UserHistory({ )} - + )} @@ -236,9 +248,13 @@ function UserHistory({ } function RatingTimeline({ + game, + playtype, data, rating, }: { + game: Game; + playtype: Playtype; data: UGPTHistory; rating: keyof UserGameStats["ratings"]; }) { @@ -259,12 +275,19 @@ function RatingTimeline({ tickSize: 5, tickPadding: 5, tickRotation: 0, - format: (y) => (y ? ToFixedFloor(y, 2) : "N/A"), + format: (y) => (y ? FormatGPTProfileRating(game, playtype, rating, y) : "N/A"), }} tooltip={(p) => (
- {p.point.data.y ? ToFixedFloor(p.point.data.y as number, 2) : "N/A"}{" "} + {p.point.data.y + ? FormatGPTProfileRating( + game, + playtype, + rating, + p.point.data.y as number + ) + : "N/A"}{" "} {UppercaseFirst(rating)}
From fffdc9c39132b7c59c0e9406df77300d75419101 Mon Sep 17 00:00:00 2001 From: beer-psi Date: Thu, 3 Oct 2024 02:23:09 +0000 Subject: [PATCH 2/5] adjust margins so the rating numbers fit --- client/src/components/charts/TimelineChart.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/components/charts/TimelineChart.tsx b/client/src/components/charts/TimelineChart.tsx index 5b3d257c5..4631556a1 100644 --- a/client/src/components/charts/TimelineChart.tsx +++ b/client/src/components/charts/TimelineChart.tsx @@ -40,7 +40,7 @@ export default function TimelineChart({
Date: Thu, 3 Oct 2024 02:26:13 +0000 Subject: [PATCH 3/5] museca: drop decimal places from profile rating --- common/src/config/game-support/museca.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/common/src/config/game-support/museca.ts b/common/src/config/game-support/museca.ts index 344ff53a0..0ab8a046d 100644 --- a/common/src/config/game-support/museca.ts +++ b/common/src/config/game-support/museca.ts @@ -70,6 +70,7 @@ export const MUSECA_SINGLE_CONF = { curatorSkill: { description: "The sum of your best 20 Curator Skills. This is identical to how it's calculated in-game.", + formatter: NoDecimalPlace, }, }, From 3bcf192dab7e361d0773c85dedddd508ee4665b3 Mon Sep 17 00:00:00 2001 From: beer-psi Date: Thu, 3 Oct 2024 02:30:19 +0000 Subject: [PATCH 4/5] adjust margins again to accommodate for wacca/jubeat/gitadora --- client/src/components/charts/TimelineChart.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/components/charts/TimelineChart.tsx b/client/src/components/charts/TimelineChart.tsx index 4631556a1..19b0057fa 100644 --- a/client/src/components/charts/TimelineChart.tsx +++ b/client/src/components/charts/TimelineChart.tsx @@ -40,7 +40,7 @@ export default function TimelineChart({
Date: Thu, 3 Oct 2024 09:38:40 +0700 Subject: [PATCH 5/5] chore: lint --- .../dashboard/games/_game/_playtype/GPTLeaderboardsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/app/pages/dashboard/games/_game/_playtype/GPTLeaderboardsPage.tsx b/client/src/app/pages/dashboard/games/_game/_playtype/GPTLeaderboardsPage.tsx index c49fbcdce..b9adde426 100644 --- a/client/src/app/pages/dashboard/games/_game/_playtype/GPTLeaderboardsPage.tsx +++ b/client/src/app/pages/dashboard/games/_game/_playtype/GPTLeaderboardsPage.tsx @@ -1,5 +1,5 @@ import { CreateUserMap } from "util/data"; -import { FormatGPTProfileRating, ToFixedFloor, UppercaseFirst } from "util/misc"; +import { FormatGPTProfileRating, UppercaseFirst } from "util/misc"; import { NumericSOV, StrSOV } from "util/sorts"; import ClassBadge from "components/game/ClassBadge"; import ScoreLeaderboard from "components/game/ScoreLeaderboard";