diff --git a/projects/backend/src/service/player.service.ts b/projects/backend/src/service/player.service.ts index 94abdc2..35537a0 100644 --- a/projects/backend/src/service/player.service.ts +++ b/projects/backend/src/service/player.service.ts @@ -123,6 +123,7 @@ export class PlayerService { */ public static async trackScore({ score, leaderboard }: ScoreSaberPlayerScoreToken) { const playerId = score.leaderboardPlayerInfo.id; + const playerName = score.leaderboardPlayerInfo.name; const player: PlayerDocument | null = await PlayerModel.findById(playerId); // Player is not tracked, so ignore the score. if (player == undefined) { @@ -151,7 +152,7 @@ export class PlayerService { await player.save(); console.log( - `Updated scores set statistic for "${player.id}", scores today: ${scores.rankedScores} ranked, ${scores.unrankedScores} unranked` + `Updated scores set statistic for "${playerName}"(${playerId}), scores today: ${scores.rankedScores} ranked, ${scores.unrankedScores} unranked` ); } } diff --git a/projects/website/src/app/(pages)/api/og/player/route.tsx b/projects/website/src/app/(pages)/api/og/player/route.tsx new file mode 100644 index 0000000..094dd31 --- /dev/null +++ b/projects/website/src/app/(pages)/api/og/player/route.tsx @@ -0,0 +1,58 @@ +import { ImageResponse } from "next/og"; +import { scoresaberService } from "@ssr/common/service/impl/scoresaber"; +import { NextRequest } from "next/server"; +import { formatNumberWithCommas, formatPp } from "@/common/number-utils"; +import { config } from "../../../../../../config"; + +export async function GET(request: NextRequest) { + const playerId = request.nextUrl.searchParams.get("id"); + if (!playerId) { + return new Response(null, { status: 400 }); + } + const player = await scoresaberService.lookupPlayer(playerId); + if (!player) { + return new Response(null, { status: 404 }); + } + + return new ImageResponse( + ( +
{player.name}
+{formatPp(player.pp)}pp
+#{formatNumberWithCommas(player.rank)}
+#{formatNumberWithCommas(player.countryRank)}
+- We're experiencing some technical difficulties. Please try again later. -
- {error?.digest &&Error Code: {error.digest}
} ++ We're experiencing some technical difficulties. Please try again later. +
+ {error?.digest &&Error Code: {error.digest}
} -