move score page fetching to the backend
This commit is contained in:
bun.lockb
projects
backend
common
package.json
src
leaderboard.ts
tsconfig.jsonleaderboard
model
player
response
score
service
types
utils
website/src
app/(pages)
common/database
components
api
friend
leaderboard
leaderboard-data.tsxleaderboard-info.tsxleaderboard-player.tsxleaderboard-score-stats.tsxleaderboard-score.tsxleaderboard-scores.tsxleaderboard-song-star-count.tsx
player
chart
player-badges.tsxplayer-data.tsxplayer-header.tsxplayer-scores.tsxplayer-stats.tsxplayer-tracked-status.tsxranking
score
14
projects/common/src/utils/leaderboard.util.ts
Normal file
14
projects/common/src/utils/leaderboard.util.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { Config } from "../config";
|
||||
import { LeaderboardResponse } from "../response/leaderboard-response";
|
||||
import { kyFetch } from "./utils";
|
||||
import { Leaderboards } from "../leaderboard";
|
||||
|
||||
/**
|
||||
* Fetches the leaderboard
|
||||
*
|
||||
* @param id the leaderboard id
|
||||
* @param leaderboard the leaderboard
|
||||
*/
|
||||
export async function fetchLeaderboard<L>(leaderboard: Leaderboards, id: string) {
|
||||
return kyFetch<LeaderboardResponse<L>>(`${Config.apiUrl}/leaderboard/${leaderboard}/${id}`);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
import { PlayerHistory } from "../types/player/player-history";
|
||||
import { PlayerHistory } from "../player/player-history";
|
||||
import { kyFetch } from "./utils";
|
||||
import { Config } from "../config";
|
||||
|
||||
|
37
projects/common/src/utils/score-utils.ts
Normal file
37
projects/common/src/utils/score-utils.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { Leaderboards } from "../leaderboard";
|
||||
import { kyFetch } from "./utils";
|
||||
import PlayerScoresResponse from "../response/player-scores-response";
|
||||
import { Config } from "../config";
|
||||
import { ScoreSort } from "../score/score-sort";
|
||||
|
||||
/**
|
||||
* Fetches the player's scores
|
||||
*
|
||||
* @param leaderboard the leaderboard
|
||||
* @param id the player id
|
||||
* @param page the page
|
||||
* @param sort the sort
|
||||
* @param search the search
|
||||
*/
|
||||
export async function fetchPlayerScores<S, L>(
|
||||
leaderboard: Leaderboards,
|
||||
id: string,
|
||||
page: number,
|
||||
sort: ScoreSort,
|
||||
search?: string
|
||||
) {
|
||||
return kyFetch<PlayerScoresResponse<S, L>>(
|
||||
`${Config.apiUrl}/scores/player/${leaderboard}/${id}/${page}/${sort}${search ? `?search=${search}` : ""}`
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the player's scores
|
||||
*
|
||||
* @param leaderboard the leaderboard
|
||||
* @param id the player id
|
||||
* @param page the page
|
||||
*/
|
||||
export async function fetchLeaderboardScores<S, L>(leaderboard: Leaderboards, id: string, page: number) {
|
||||
return kyFetch<PlayerScoresResponse<S, L>>(`${Config.apiUrl}/scores/leaderboard/${leaderboard}/${id}/${page}`);
|
||||
}
|
@ -1,9 +1,11 @@
|
||||
import { Difficulty } from "../score/difficulty";
|
||||
|
||||
/**
|
||||
* Formats the ScoreSaber difficulty number
|
||||
*
|
||||
* @param diff the diffuiclity number
|
||||
*/
|
||||
export function getDifficultyFromScoreSaberDifficulty(diff: number) {
|
||||
export function getDifficultyFromScoreSaberDifficulty(diff: number): Difficulty {
|
||||
switch (diff) {
|
||||
case 1: {
|
||||
return "Easy";
|
||||
|
Reference in New Issue
Block a user