From aecc216128568754b2abd355fda0969ddabd73eb Mon Sep 17 00:00:00 2001 From: Rian8337 <52914632+Rian8337@users.noreply.github.com> Date: Tue, 12 Nov 2024 13:04:13 +0800 Subject: [PATCH] Remove unused dpp processor backend endpoints --- .../pp/PPSubmissionOperationResult.ts | 26 -- src/structures/pp/PPSubmissionStatus.ts | 24 -- src/utils/managers/DPPProcessorRESTManager.ts | 359 ------------------ 3 files changed, 409 deletions(-) delete mode 100644 src/structures/pp/PPSubmissionOperationResult.ts delete mode 100644 src/structures/pp/PPSubmissionStatus.ts diff --git a/src/structures/pp/PPSubmissionOperationResult.ts b/src/structures/pp/PPSubmissionOperationResult.ts deleted file mode 100644 index 5cf3e0dba..000000000 --- a/src/structures/pp/PPSubmissionOperationResult.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { PPSubmissionStatus } from "./PPSubmissionStatus"; - -/** - * Represents the result of a pp submission operation. - */ -export interface PPSubmissionOperationResult { - /** - * The amount of pp gained from the operation. - */ - readonly ppGained: number; - - /** - * The new total pp of the player. - */ - readonly newTotalPP: number; - - /** - * The increment towards the player's play count. - */ - readonly playCountIncrement: number; - - /** - * The statuses of submissions. - */ - readonly statuses: PPSubmissionStatus[]; -} diff --git a/src/structures/pp/PPSubmissionStatus.ts b/src/structures/pp/PPSubmissionStatus.ts deleted file mode 100644 index 654bc9ca2..000000000 --- a/src/structures/pp/PPSubmissionStatus.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Represents the status of a pp submission operation. - */ -export interface PPSubmissionStatus { - /** - * Whether the operation was successful. - */ - success: boolean; - - /** - * The reason for failure. - */ - reason?: string; - - /** - * Whether the replay file needs to be persisted. - */ - replayNeedsPersistence?: boolean; - - /** - * The calculated pp value. - */ - pp: number; -} diff --git a/src/utils/managers/DPPProcessorRESTManager.ts b/src/utils/managers/DPPProcessorRESTManager.ts index 23841de8f..aa94dbc17 100644 --- a/src/utils/managers/DPPProcessorRESTManager.ts +++ b/src/utils/managers/DPPProcessorRESTManager.ts @@ -20,7 +20,6 @@ import { DroidPerformanceAttributes } from "@structures/difficultyattributes/Dro import { OsuPerformanceAttributes } from "@structures/difficultyattributes/OsuPerformanceAttributes"; import { PerformanceAttributes } from "@structures/difficultyattributes/PerformanceAttributes"; import { RebalanceDroidPerformanceAttributes } from "@structures/difficultyattributes/RebalanceDroidPerformanceAttributes"; -import { PPSubmissionOperationResult } from "@structures/pp/PPSubmissionOperationResult"; import { PPProcessorCalculationResponse } from "@structures/utils/PPProcessorCalculationResponse"; /** @@ -545,364 +544,6 @@ export abstract class PPProcessorRESTManager extends RESTManager { return JSON.parse(result.data.toString("utf-8")); } - /** - * Get the best performance of a player in a beatmap. - * - * @param playerId The ID of the player. - * @param beatmapHash The MD5 hash of the beatmap. - * @param calculationMethod The calculation method to use. - * @param generateStrainChart Whether to generate a strain chart. - * @returns The difficulty and performance attributes representing the best difficulty and performance - * of the player's score in the beatmap, `null` if the attributes cannot be retrieved. - */ - static async getBestScorePerformance< - THasStrainChart extends boolean = false, - >( - playerId: number, - beatmapHash: string, - calculationMethod: PPCalculationMethod.live, - generateStrainChart?: THasStrainChart, - ): Promise, - THasStrainChart - > | null>; - - /** - * Get the best performance of a player in a beatmap. - * - * @param playerId The ID of the player. - * @param beatmapHash The MD5 hash of the beatmap. - * @param calculationMethod The calculation method to use. - * @param generateStrainChart Whether to generate a strain chart. - * @returns The difficulty and performance attributes representing the best difficulty and performance - * of the player's score in the beatmap, `null` if the attributes cannot be retrieved. - */ - static async getBestScorePerformance< - THasStrainChart extends boolean = false, - >( - playerId: number, - beatmapHash: string, - calculationMethod: PPCalculationMethod.rebalance, - generateStrainChart?: THasStrainChart, - ): Promise, - THasStrainChart - > | null>; - - static async getBestScorePerformance< - THasStrainChart extends boolean = false, - >( - playerId: number, - beatmapHash: string, - calculationMethod: PPCalculationMethod, - generateStrainChart?: THasStrainChart, - ): Promise, - THasStrainChart - > | null> { - const url = new URL( - `${this.endpoint}get-player-best-score-performance`, - ); - - url.searchParams.set("key", process.env.DROID_SERVER_INTERNAL_KEY!); - url.searchParams.set("playerid", playerId.toString()); - url.searchParams.set("beatmaphash", beatmapHash); - url.searchParams.set("calculationmethod", calculationMethod.toString()); - - if (generateStrainChart) { - url.searchParams.set("generatestrainchart", "1"); - } - - const result = await this.request(url).catch(() => null); - - if (result?.statusCode !== 200) { - this.logError(url, result); - - return null; - } - - return JSON.parse(result.data.toString("utf-8")); - } - - /** - * Get the performance of a player's persisted replay in a beatmap. - * - * @param playerId The ID of the player. - * @param beatmapHash The MD5 hash of the beatmap. - * @param mods The mods used in the replay. - * @param customSpeedMultiplier The custom speed multiplier used in the replay. - * @param gamemode The gamemode to calculate. - * @param calculationMethod The calculation method to use. - * @param generateStrainChart Whether to generate a strain chart. - * @returns The difficulty and performance attributes representing the difficulty and performance - * of the replay, `null` if the attributes cannot be retrieved. - */ - static async calculatePersistedReplay( - playerId: number, - beatmapHash: string, - mods: string, - customSpeedMultiplier: number, - gamemode: Modes.droid, - calculationMethod: PPCalculationMethod.live, - generateStrainChart?: THasStrainChart, - ): Promise, - THasStrainChart - > | null>; - - /** - * Get the performance of a player's persisted replay in a beatmap. - * - * @param playerId The ID of the player. - * @param beatmapHash The MD5 hash of the beatmap. - * @param mods The mods used in the replay. - * @param customSpeedMultiplier The custom speed multiplier used in the replay. - * @param gamemode The gamemode to calculate. - * @param calculationMethod The calculation method to use. - * @param generateStrainChart Whether to generate a strain chart. - * @returns The difficulty and performance attributes representing the difficulty and performance - * of the replay, `null` if the attributes cannot be retrieved. - */ - static async calculatePersistedReplay( - playerId: number, - beatmapHash: string, - mods: string, - customSpeedMultiplier: number, - gamemode: Modes.droid, - calculationMethod: PPCalculationMethod.rebalance, - generateStrainChart?: THasStrainChart, - ): Promise, - THasStrainChart - > | null>; - - /** - * Get the performance of a player's persisted replay in a beatmap. - * - * @param playerId The ID of the player. - * @param beatmapHash The MD5 hash of the beatmap. - * @param mods The mods used in the replay. - * @param customSpeedMultiplier The custom speed multiplier used in the replay. - * @param gamemode The gamemode to calculate. - * @param calculationMethod The calculation method to use. - * @param generateStrainChart Whether to generate a strain chart. - * @returns The difficulty and performance attributes representing the difficulty and performance - * of the replay, `null` if the attributes cannot be retrieved. - */ - static async calculatePersistedReplay( - playerId: number, - beatmapHash: string, - mods: string, - customSpeedMultiplier: number, - gamemode: Modes.osu, - calculationMethod: PPCalculationMethod.live, - generateStrainChart?: THasStrainChart, - ): Promise, - THasStrainChart - > | null>; - - /** - * Get the performance of a player's persisted replay in a beatmap. - * - * @param playerId The ID of the player. - * @param beatmapHash The MD5 hash of the beatmap. - * @param mods The mods used in the replay. - * @param customSpeedMultiplier The custom speed multiplier used in the replay. - * @param gamemode The gamemode to calculate. - * @param calculationMethod The calculation method to use. - * @param generateStrainChart Whether to generate a strain chart. - * @returns The difficulty and performance attributes representing the difficulty and performance - * of the replay, `null` if the attributes cannot be retrieved. - */ - static async calculatePersistedReplay( - playerId: number, - beatmapHash: string, - mods: string, - customSpeedMultiplier: number, - gamemode: Modes.osu, - calculationMethod: PPCalculationMethod.rebalance, - generateStrainChart?: THasStrainChart, - ): Promise, - THasStrainChart - > | null>; - - static async calculatePersistedReplay( - playerId: number, - beatmapHash: string, - mods: string, - customSpeedMultiplier: number, - gamemode: Modes, - calculationMethod: PPCalculationMethod, - generateStrainChart?: THasStrainChart, - ): Promise, - THasStrainChart - > | null> { - const url = new URL(`${this.endpoint}calculate-persisted-replay`); - - url.searchParams.set("key", process.env.DROID_SERVER_INTERNAL_KEY!); - url.searchParams.set("playerid", playerId.toString()); - url.searchParams.set("beatmaphash", beatmapHash); - url.searchParams.set("mods", mods); - url.searchParams.set( - "customspeedmultiplier", - customSpeedMultiplier.toString(), - ); - url.searchParams.set("gamemode", gamemode); - url.searchParams.set("calculationmethod", calculationMethod.toString()); - - if (generateStrainChart) { - url.searchParams.set("generatestrainchart", "1"); - } - - const result = await this.request(url).catch(() => null); - - if (result?.statusCode !== 200) { - this.logError(url, result); - - return null; - } - - return JSON.parse(result.data.toString("utf-8")); - } - - /** - * Sends a score submission request to the backend. - * - * @param playerId The ID of the player of which the score belongs to. - * @param scoreIds The ID of the scores to be submitted. - * @returns The status of the submission for each score ID, `null` if the server fails to be reached. - */ - static async submitScores( - playerId: number, - scoreIds: number[], - ): Promise { - const url = new URL(`${this.endpoint}submit-scores`); - const result = await this.request(url, { - method: "POST", - body: { - key: process.env.DROID_SERVER_INTERNAL_KEY, - uid: playerId, - scoreids: scoreIds.join(","), - }, - json: true, - }).catch(() => null); - - if (result?.statusCode !== 200) { - this.logError(url, result); - - return null; - } - - return JSON.parse(result.data.toString("utf-8")); - } - - /** - * Persists a local replay file of a player. - * - * @param playerId The ID of the player. - * @param beatmapHash The MD5 hash of the beatmap where the replay resides. - * @param replayHash The MD5 hash of the replay file. - * @returns Whether the replay file was successfully persisted. - */ - static async persistLocalReplay( - playerId: number, - beatmapHash: string, - replayHash: string, - ): Promise { - const url = new URL(`${this.endpoint}persist-local-replay`); - const result = await this.request(url, { - method: "PUT", - body: { - key: process.env.DROID_SERVER_INTERNAL_KEY, - playerid: playerId, - beatmaphash: beatmapHash, - replayhash: replayHash, - }, - json: true, - }); - - if (result?.statusCode !== 200) { - if (result) { - consola.error( - "Request to %s failed with error: %s", - url - .toString() - .replace(process.env.DROID_SERVER_INTERNAL_KEY!, ""), - result.data.toString("utf-8"), - ); - } else { - consola.error( - "Request to %s failed with unknown error", - url - .toString() - .replace(process.env.DROID_SERVER_INTERNAL_KEY!, ""), - ); - } - - return false; - } - - return true; - } - - /** - * Persists an online replay file of a player. - * - * @param playerId The ID of the player. - * @param scoreId The ID of the score. - * @returns Whether the replay file was successfully persisted. - */ - static async persistOnlineReplay( - playerId: number, - scoreId: number, - ): Promise { - const url = new URL(`${this.endpoint}persist-online-replay`); - const result = await this.request(url, { - method: "PUT", - body: { - key: process.env.DROID_SERVER_INTERNAL_KEY, - uid: playerId, - scoreid: scoreId, - }, - json: true, - }); - - if (result?.statusCode !== 200) { - this.logError(url, result); - - return false; - } - - return true; - } - /** * Logs the error of a request. *