Skip to content

Commit

Permalink
feat: consolidate /recentgames, /dropper, /partygames and /bridge (#684)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobk999 authored Aug 19, 2024
1 parent bc6c2a9 commit ce9567f
Show file tree
Hide file tree
Showing 55 changed files with 508 additions and 982 deletions.
18 changes: 0 additions & 18 deletions apps/api/src/player/player.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ import {
DeletePlayerResponse,
ErrorResponse,
GetPlayerResponse,
GetRecentGamesResponse,
GetStatusResponse,
PlayerNotFoundException,
RecentGamesNotFoundException,
StatusNotFoundException,
} from "@statsify/api-client";

Expand Down Expand Up @@ -78,22 +76,6 @@ export class PlayerController {
};
}

@ApiOperation({ summary: "Get the Recent Games of a Player" })
@ApiOkResponse({ type: GetRecentGamesResponse })
@ApiBadRequestResponse({ type: ErrorResponse })
@ApiNotFoundResponse({ type: RecentGamesNotFoundException })
@ApiNotFoundResponse({ type: PlayerNotFoundException })
@Auth()
@Get("/recentgames")
public async getRecentGames(@Query() { player: tag }: PlayerDto) {
const recentGames = await this.playerService.getRecentGames(tag);

return {
success: !!recentGames,
recentGames,
};
}

@ApiOperation({ summary: "Get the Status of a Player" })
@ApiOkResponse({ type: GetStatusResponse })
@ApiBadRequestResponse({ type: ErrorResponse })
Expand Down
29 changes: 5 additions & 24 deletions apps/api/src/player/player.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import { type APIData, type Circular, type Flatten, flatten } from "@statsify/util";
import {
CacheLevel,
PlayerNotFoundException,
RecentGamesNotFoundException,
StatusNotFoundException,
} from "@statsify/api-client";
import { HypixelService } from "#hypixel";
Expand Down Expand Up @@ -115,39 +113,22 @@ export class PlayerService {

if (!player) throw new NotFoundException("player");

const status = await this.hypixelService.getStatus(player.uuid);
const [status, games] = await Promise.all([
this.hypixelService.getStatus(player.uuid),
this.hypixelService.getRecentGames(player.uuid),
]);

if (!status) throw new StatusNotFoundException(player);

status.displayName = player.displayName;
status.prefixName = player.prefixName;
status.uuid = player.uuid;
status.actions = player.status;
status.recentGames = games;

return status;
}

public async getRecentGames(tag: string) {
const player = await this.get(tag, CacheLevel.CACHE_ONLY, {
uuid: true,
displayName: true,
prefixName: true,
});

if (!player) throw new PlayerNotFoundException();

const games = await this.hypixelService.getRecentGames(player.uuid);

if (!games || !games.length) throw new RecentGamesNotFoundException(player);

return {
uuid: player.uuid,
displayName: player.displayName,
prefixName: player.prefixName,
games,
};
}

/**
*
* @param tag UUID or Username of the player
Expand Down
6 changes: 3 additions & 3 deletions apps/discord-bot/src/commands/arcade/arcade.profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const ArcadeProfile = ({
break;

case "dropper":
table = <DropperTable stats={arcade[api]} t={t} time={time} />;
table = <DropperTable stats={arcade[api]} t={t} time={time} submode={mode.submode} />;
break;

case "enderSpleef":
Expand Down Expand Up @@ -112,7 +112,7 @@ export const ArcadeProfile = ({
break;

case "partyGames":
table = <PartyGamesTable stats={arcade[api]} t={t} />;
table = <PartyGamesTable stats={arcade[api]} t={t} submode={mode.submode} time={time} />;
break;

case "pixelPainters":
Expand Down Expand Up @@ -149,7 +149,7 @@ export const ArcadeProfile = ({
sidebar={sidebar}
title={`§l${FormattedGame.ARCADE} §f${
api === "overall" ? t("stats.wins") : "Stats"
} §r(${mode.formatted})`}
} §r(${mode.formatted}${mode.submode ? ` ${mode.submode.formatted}` : ""})`}
time={time}
/>
{table}
Expand Down
30 changes: 0 additions & 30 deletions apps/discord-bot/src/commands/arcade/dropper.command.tsx

This file was deleted.

66 changes: 0 additions & 66 deletions apps/discord-bot/src/commands/arcade/dropper.profile.tsx

This file was deleted.

70 changes: 0 additions & 70 deletions apps/discord-bot/src/commands/arcade/modes/dropper-maps.tsx

This file was deleted.

Loading

0 comments on commit ce9567f

Please sign in to comment.