mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-03-21 18:04:39 -05:00
Fix how score is shown on voting results
This commit is contained in:
parent
35018a091a
commit
67a13b8515
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -6,6 +6,7 @@ node_modules
|
|||
.env
|
||||
|
||||
db*.sqlite3*
|
||||
dump
|
||||
|
||||
/cypress/videos
|
||||
/cypress/screenshots
|
||||
|
|
|
|||
|
|
@ -49,13 +49,15 @@ export const loader: LoaderFunction = async ({ request }) => {
|
|||
|
||||
return json<PlusVotingResultsLoaderData>({
|
||||
results,
|
||||
ownScores: ownScores?.map(maybeHideScore),
|
||||
ownScores: ownScores?.map(scoreForDisplaying),
|
||||
});
|
||||
};
|
||||
|
||||
export default function PlusVotingResultsPage() {
|
||||
const data = useLoaderData<PlusVotingResultsLoaderData>();
|
||||
|
||||
console.log({ data });
|
||||
|
||||
const { month, year } = lastCompletedVoting(new Date());
|
||||
|
||||
return (
|
||||
|
|
@ -75,7 +77,7 @@ export default function PlusVotingResultsPage() {
|
|||
)}{" "}
|
||||
the +{result.tier} voting
|
||||
{result.score
|
||||
? `, your score was ${result.score} (at least 0.5 required to pass)`
|
||||
? `, your score was ${result.score}% (at least 50% required to pass)`
|
||||
: ""}
|
||||
</li>
|
||||
))}
|
||||
|
|
@ -134,14 +136,20 @@ function Results({
|
|||
);
|
||||
}
|
||||
|
||||
function maybeHideScore(
|
||||
function databaseAvgToPercentage(score: number) {
|
||||
const scoreNormalized = score + 1;
|
||||
|
||||
return roundToTwoDecimalPlaces((scoreNormalized / 2) * 100);
|
||||
}
|
||||
|
||||
function scoreForDisplaying(
|
||||
score: Unpacked<NonNullable<PlusVotingResultByMonthYear["ownScores"]>>
|
||||
) {
|
||||
const showScore = score.wasSuggested && !score.passedVoting;
|
||||
|
||||
return {
|
||||
tier: score.tier,
|
||||
score: showScore ? roundToTwoDecimalPlaces(score.score) : undefined,
|
||||
score: showScore ? databaseAvgToPercentage(score.score) : undefined,
|
||||
passedVoting: score.passedVoting,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user