fix
Some checks failed
Deploy Backend / deploy (push) Successful in 4m14s
Deploy Website / deploy (push) Failing after 2m42s

This commit is contained in:
Lee 2024-10-15 19:43:23 +01:00
parent 970ab22e2f
commit f2ef170f01
14 changed files with 33 additions and 32 deletions

@ -11,6 +11,6 @@ export default class ImageController {
}), }),
}) })
public async getOpenGraphImage({ params: { id } }: { params: { id: string } }) { public async getOpenGraphImage({ params: { id } }: { params: { id: string } }) {
return await ImageService.generateOpenGraphImage(id); return await ImageService.generatePlayerImage(id);
} }
} }

@ -1,7 +1,7 @@
import { ImageResponse } from "@vercel/og"; import { ImageResponse } from "@vercel/og";
import { scoresaberService } from "@ssr/common/service/impl/scoresaber"; import { scoresaberService } from "@ssr/common/service/impl/scoresaber";
import { formatNumberWithCommas, formatPp } from "website/src/common/number-utils";
import React from "react"; import React from "react";
import { formatNumberWithCommas, formatPp } from "@ssr/common/utils/number-utils";
export class ImageService { export class ImageService {
/** /**
@ -9,7 +9,7 @@ export class ImageService {
* *
* @param id the player's id * @param id the player's id
*/ */
public static async generateOpenGraphImage(id: string) { public static async generatePlayerImage(id: string) {
const player = await scoresaberService.lookupPlayer(id); const player = await scoresaberService.lookupPlayer(id);
if (player == undefined) { if (player == undefined) {
return undefined; return undefined;

@ -7,3 +7,23 @@
export function isWholeNumber(number: number) { export function isWholeNumber(number: number) {
return number % 1 === 0; return number % 1 === 0;
} }
/**
* Formats a number without trailing zeros.
*
* @param num the number to format
* @returns the formatted number
*/
export function formatNumberWithCommas(num: number) {
return num.toLocaleString();
}
/**
* Formats the pp value
*
* @param num the pp to format
* @returns the formatted pp
*/
export function formatPp(num: number) {
return num.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
}

@ -1,19 +0,0 @@
/**
* Formats a number without trailing zeros.
*
* @param num the number to format
* @returns the formatted number
*/
export function formatNumberWithCommas(num: number) {
return num.toLocaleString();
}
/**
* Formats the pp value
*
* @param num the pp to format
* @returns the formatted pp
*/
export function formatPp(num: number) {
return num.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
}

@ -1,6 +1,6 @@
"use client"; "use client";
import { formatNumberWithCommas } from "@/common/number-utils"; import { formatNumberWithCommas } from "@ssr/common/utils/number-utils";
import { zodResolver } from "@hookform/resolvers/zod"; import { zodResolver } from "@hookform/resolvers/zod";
import Link from "next/link"; import Link from "next/link";
import { useState } from "react"; import { useState } from "react";

@ -1,4 +1,4 @@
import { formatNumberWithCommas } from "@/common/number-utils"; import { formatNumberWithCommas } from "@ssr/common/utils/number-utils";
import { XMarkIcon } from "@heroicons/react/24/solid"; import { XMarkIcon } from "@heroicons/react/24/solid";
import clsx from "clsx"; import clsx from "clsx";
import { getScoreBadgeFromAccuracy } from "@/common/song-utils"; import { getScoreBadgeFromAccuracy } from "@/common/song-utils";

@ -1,6 +1,6 @@
"use client"; "use client";
import { formatNumberWithCommas } from "@/common/number-utils"; import { formatNumberWithCommas } from "@ssr/common/utils/number-utils";
import React from "react"; import React from "react";
import { DatasetConfig } from "@/components/chart/generic-chart"; import { DatasetConfig } from "@/components/chart/generic-chart";
import GenericPlayerChart from "@/components/player/chart/generic-player-chart"; import GenericPlayerChart from "@/components/player/chart/generic-player-chart";

@ -1,4 +1,4 @@
import { formatNumberWithCommas, formatPp } from "@/common/number-utils"; import { formatNumberWithCommas, formatPp } from "@ssr/common/utils/number-utils";
import { GlobeAmericasIcon } from "@heroicons/react/24/solid"; import { GlobeAmericasIcon } from "@heroicons/react/24/solid";
import Card from "../card"; import Card from "../card";
import CountryFlag from "../country-flag"; import CountryFlag from "../country-flag";

@ -1,4 +1,4 @@
import { formatNumberWithCommas } from "@/common/number-utils"; import { formatNumberWithCommas } from "@ssr/common/utils/number-utils";
import StatValue from "@/components/stat-value"; import StatValue from "@/components/stat-value";
import ScoreSaberPlayer from "@ssr/common/types/player/impl/scoresaber-player"; import ScoreSaberPlayer from "@ssr/common/types/player/impl/scoresaber-player";

@ -5,7 +5,7 @@ import ky from "ky";
import { config } from "../../../config"; import { config } from "../../../config";
import Tooltip from "@/components/tooltip"; import Tooltip from "@/components/tooltip";
import { InformationCircleIcon } from "@heroicons/react/16/solid"; import { InformationCircleIcon } from "@heroicons/react/16/solid";
import { formatNumberWithCommas } from "@/common/number-utils"; import { formatNumberWithCommas } from "@ssr/common/utils/number-utils";
import { PlayerTrackedSince } from "@ssr/common/types/player/player-tracked-since"; import { PlayerTrackedSince } from "@ssr/common/types/player/player-tracked-since";
import ScoreSaberPlayer from "@ssr/common/types/player/impl/scoresaber-player"; import ScoreSaberPlayer from "@ssr/common/types/player/impl/scoresaber-player";

@ -1,4 +1,4 @@
import { formatNumberWithCommas, formatPp } from "@/common/number-utils"; import { formatNumberWithCommas, formatPp } from "@ssr/common/utils/number-utils";
import { GlobeAmericasIcon } from "@heroicons/react/24/solid"; import { GlobeAmericasIcon } from "@heroicons/react/24/solid";
import { useQuery } from "@tanstack/react-query"; import { useQuery } from "@tanstack/react-query";
import Link from "next/link"; import Link from "next/link";

@ -1,6 +1,6 @@
"use client"; "use client";
import { formatNumberWithCommas, formatPp } from "@/common/number-utils"; import { formatNumberWithCommas, formatPp } from "@ssr/common/utils/number-utils";
import CountryFlag from "@/components/country-flag"; import CountryFlag from "@/components/country-flag";
import ScoreSaberPlayerToken from "@ssr/common/types/token/scoresaber/score-saber-player-token"; import ScoreSaberPlayerToken from "@ssr/common/types/token/scoresaber/score-saber-player-token";
import Link from "next/link"; import Link from "next/link";

@ -1,4 +1,4 @@
import { formatNumberWithCommas } from "@/common/number-utils"; import { formatNumberWithCommas } from "@ssr/common/utils/number-utils";
import { format } from "@formkit/tempo"; import { format } from "@formkit/tempo";
import { GlobeAmericasIcon } from "@heroicons/react/24/solid"; import { GlobeAmericasIcon } from "@heroicons/react/24/solid";
import Tooltip from "../tooltip"; import Tooltip from "../tooltip";

@ -1,4 +1,4 @@
import { formatNumberWithCommas, formatPp } from "@/common/number-utils"; import { formatNumberWithCommas, formatPp } from "@ssr/common/utils/number-utils";
import { getScoreBadgeFromAccuracy } from "@/common/song-utils"; import { getScoreBadgeFromAccuracy } from "@/common/song-utils";
import { XMarkIcon } from "@heroicons/react/24/solid"; import { XMarkIcon } from "@heroicons/react/24/solid";
import clsx from "clsx"; import clsx from "clsx";