mirror of
https://github.com/amineo/t2-stat-parser.git
synced 2026-04-29 15:35:24 +00:00
tweak return details
This commit is contained in:
parent
c10cd44615
commit
98affddbff
4 changed files with 15 additions and 11 deletions
|
|
@ -28,8 +28,9 @@ export class GamesController {
|
||||||
// /games/gametype/:gametype
|
// /games/gametype/:gametype
|
||||||
@Get('gametype/:gametype')
|
@Get('gametype/:gametype')
|
||||||
@ApiOperation({ tags: [ 'Game' ], summary: 'Return the latest games by game type' })
|
@ApiOperation({ tags: [ 'Game' ], summary: 'Return the latest games by game type' })
|
||||||
findByType(@Param('gametype') gametype: string) {
|
findByType(@Param('gametype') gametype: string, @Query() paginationQuery: PaginationQueryDto) {
|
||||||
return this.gamesService.findByType(gametype);
|
const { limit = 10, offset = 0 } = paginationQuery;
|
||||||
|
return this.gamesService.findByType(gametype, { limit, offset });
|
||||||
}
|
}
|
||||||
|
|
||||||
// /games/gametype/CTFGame/summary
|
// /games/gametype/CTFGame/summary
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,8 @@ export class GamesService {
|
||||||
abvSummary.push(summary);
|
abvSummary.push(summary);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only return games when the score is 100 or greater
|
// Only return games when the score is greater than 1
|
||||||
return abvSummary.filter((g) => g.totalScore >= 100);
|
return abvSummary.filter((g) => g.totalScore > 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
async findAllWithSummary(paginationQuery: PaginationQueryDto) {
|
async findAllWithSummary(paginationQuery: PaginationQueryDto) {
|
||||||
|
|
@ -60,11 +60,14 @@ export class GamesService {
|
||||||
return withSummary;
|
return withSummary;
|
||||||
}
|
}
|
||||||
|
|
||||||
async findByType(gametype: string) {
|
async findByType(gametype: string, paginationQuery: PaginationQueryDto) {
|
||||||
|
const { limit, offset } = paginationQuery;
|
||||||
|
const returnMaxLimit = Math.min(100, Math.max(0, limit));
|
||||||
|
|
||||||
const games = await this.gamesRepository.find({
|
const games = await this.gamesRepository.find({
|
||||||
where: { gametype: gametype },
|
where: { gametype: gametype },
|
||||||
skip: 0,
|
skip: offset,
|
||||||
take: 10,
|
take: returnMaxLimit,
|
||||||
order: {
|
order: {
|
||||||
gameId: 'DESC'
|
gameId: 'DESC'
|
||||||
}
|
}
|
||||||
|
|
@ -79,8 +82,8 @@ export class GamesService {
|
||||||
abvSummary.push(summary);
|
abvSummary.push(summary);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only return games when the score is 100 or greater
|
// Only return games when the score is greater than 1
|
||||||
return abvSummary.filter((g) => g.totalScore >= 100);
|
return abvSummary.filter((g) => g.totalScore > 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
async findByTypeWithSummary(gametype: string, paginationQuery: PaginationQueryDto) {
|
async findByTypeWithSummary(gametype: string, paginationQuery: PaginationQueryDto) {
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ export class PlayerService {
|
||||||
Number(player.totalGamesDmgame) +
|
Number(player.totalGamesDmgame) +
|
||||||
Number(player.totalGamesSctfgame) +
|
Number(player.totalGamesSctfgame) +
|
||||||
Number(player.totalGamesLakrabbitgame),
|
Number(player.totalGamesLakrabbitgame),
|
||||||
gameDetails: gameDetails.sort((a, b) => b.id - a.id),
|
gameDetails: gameDetails.sort((a, b) => b.id - a.id).filter((g) => g.stats.scoreTG > 0),
|
||||||
statTotals: playerStatTotals
|
statTotals: playerStatTotals
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ services:
|
||||||
replicas: 1
|
replicas: 1
|
||||||
|
|
||||||
api:
|
api:
|
||||||
image: "amineo/t2-stats-api:v0.0.10"
|
image: "amineo/t2-stats-api:v0.0.12"
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: ./build/api/Dockerfile
|
dockerfile: ./build/api/Dockerfile
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue