fix player data not showing when claiming the profile
Some checks failed
Deploy Backend / deploy (push) Failing after 1m5s
Deploy Website / deploy (push) Failing after 1m29s

This commit is contained in:
Lee 2024-10-17 02:40:18 +01:00
parent ae4e6912e5
commit 42d133bbbb
5 changed files with 9 additions and 38 deletions

@ -1,29 +0,0 @@
name: Fix bun lock file (Renovate)
on:
workflow_dispatch:
push:
branches-ignore:
- master
paths:
- '**/package.json' # Detect changes in any package.json file in any directory
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install bun
uses: oven-sh/setup-bun@v2
- name: Install dependencies
run: bun install
- name: Commit bun lock file
run: |
git config --global user.email "helper@fascinated.cc"
git config --global user.name "Bun Fixer"
git add bun.lockb
git commit -m "Fix bun lock file"
git push

@ -4,6 +4,9 @@ import { PlayerHistory } from "../player-history";
import ScoreSaberPlayerToken from "../../token/scoresaber/score-saber-player-token"; import ScoreSaberPlayerToken from "../../token/scoresaber/score-saber-player-token";
import { formatDateMinimal, getDaysAgoDate, getMidnightAlignedDate } from "../../../utils/time-utils"; import { formatDateMinimal, getDaysAgoDate, getMidnightAlignedDate } from "../../../utils/time-utils";
import { getPageFromRank } from "../../../utils/utils"; import { getPageFromRank } from "../../../utils/utils";
import { getCookieValue } from "website/src/common/cookie-utils";
import { db } from "website/src/common/database/database";
import { isServer } from "@tanstack/react-query";
/** /**
* A ScoreSaber player. * A ScoreSaber player.
@ -76,12 +79,10 @@ export default interface ScoreSaberPlayer extends Player {
* *
* @param token the player token * @param token the player token
* @param apiUrl the api url for SSR * @param apiUrl the api url for SSR
* @param playerIdCookie the player id cookie (doesn't need to be set)
*/ */
export async function getScoreSaberPlayerFromToken( export async function getScoreSaberPlayerFromToken(
token: ScoreSaberPlayerToken, token: ScoreSaberPlayerToken,
apiUrl: string, apiUrl: string
playerIdCookie?: string
): Promise<ScoreSaberPlayer> { ): Promise<ScoreSaberPlayer> {
const bio: ScoreSaberBio = { const bio: ScoreSaberBio = {
lines: token.bio?.split("\n") || [], lines: token.bio?.split("\n") || [],
@ -99,6 +100,8 @@ export async function getScoreSaberPlayerFromToken(
let isBeingTracked = false; let isBeingTracked = false;
const todayDate = formatDateMinimal(getMidnightAlignedDate(new Date())); const todayDate = formatDateMinimal(getMidnightAlignedDate(new Date()));
let statisticHistory: { [key: string]: PlayerHistory } = {}; let statisticHistory: { [key: string]: PlayerHistory } = {};
const playerIdCookie = isServer ? await getCookieValue("playerId") : (await db.getSettings())?.playerId;
try { try {
const { statistics: history } = await ky const { statistics: history } = await ky
.get<{ .get<{

@ -55,8 +55,7 @@ const getPlayerData = async ({ params }: Props, fetchScores: boolean = true): Pr
} }
const playerToken = await scoresaberService.lookupPlayer(id); const playerToken = await scoresaberService.lookupPlayer(id);
const player = const player = playerToken && (await getScoreSaberPlayerFromToken(playerToken, config.siteApi));
playerToken && (await getScoreSaberPlayerFromToken(playerToken, config.siteApi, await getCookieValue("playerId")));
let scores: ScoreSaberPlayerScoresPageToken | undefined; let scores: ScoreSaberPlayerScoresPageToken | undefined;
if (fetchScores) { if (fetchScores) {
scores = await scoresaberService.lookupPlayerScores({ scores = await scoresaberService.lookupPlayerScores({

@ -16,7 +16,7 @@ export function ApiHealth() {
useQuery({ useQuery({
queryKey: ["api-health"], queryKey: ["api-health"],
queryFn: async () => { queryFn: async () => {
const status = (await getApiHealth(config.siteApi)).online; const status = (await getApiHealth(config.siteApi + "/health")).online;
setOnline(status); setOnline(status);
return status; return status;
}, },

@ -17,7 +17,6 @@ import { scoresaberService } from "@ssr/common/service/impl/scoresaber";
import { config } from "../../../config"; import { config } from "../../../config";
import useDatabase from "@/hooks/use-database"; import useDatabase from "@/hooks/use-database";
import { useLiveQuery } from "dexie-react-hooks"; import { useLiveQuery } from "dexie-react-hooks";
import { getCookieValue } from "@/common/cookie-utils";
const REFRESH_INTERVAL = 1000 * 60 * 5; const REFRESH_INTERVAL = 1000 * 60 * 5;
@ -50,9 +49,8 @@ export default function PlayerData({
if (playerResponse == undefined) { if (playerResponse == undefined) {
return undefined; return undefined;
} }
return await getScoreSaberPlayerFromToken(playerResponse, config.siteApi, await getCookieValue("playerId")); return await getScoreSaberPlayerFromToken(playerResponse, config.siteApi);
}, },
staleTime: REFRESH_INTERVAL,
refetchInterval: REFRESH_INTERVAL, refetchInterval: REFRESH_INTERVAL,
refetchIntervalInBackground: false, refetchIntervalInBackground: false,
}); });