AI Implementation feature(865): Scoreboard: Ranking, Matrix, Event Log and Score Graph (#52)
This commit was merged in pull request #52.
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import { Controller, Get, Query } from '@nestjs/common';
|
||||
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import { DataSource } from 'typeorm';
|
||||
import { ZodValidationPipe } from '../../common/pipes/zod-validation.pipe';
|
||||
import { ScoreboardService } from './scoreboard.service';
|
||||
import {
|
||||
EventLogQuerySchema,
|
||||
EventLogRowDto,
|
||||
GraphViewDto,
|
||||
MatrixViewDto,
|
||||
RankingRowDto,
|
||||
} from './dto/scoreboard.dto';
|
||||
|
||||
@ApiTags('scoreboard')
|
||||
@ApiBearerAuth()
|
||||
@Controller('api/v1/scoreboard')
|
||||
export class ScoreboardController {
|
||||
constructor(
|
||||
private readonly dataSource: DataSource,
|
||||
private readonly svc: ScoreboardService,
|
||||
) {}
|
||||
|
||||
@Get('ranking')
|
||||
@ApiOperation({ summary: 'Authenticated scoreboard ranking (competition ranks)' })
|
||||
async ranking(): Promise<RankingRowDto[]> {
|
||||
return this.svc.getRanking(this.dataSource.manager);
|
||||
}
|
||||
|
||||
@Get('matrix')
|
||||
@ApiOperation({ summary: 'Authenticated scoreboard matrix (players x challenges)' })
|
||||
async matrix(): Promise<MatrixViewDto> {
|
||||
return this.svc.getMatrix(this.dataSource.manager);
|
||||
}
|
||||
|
||||
@Get('event-log')
|
||||
@ApiOperation({ summary: 'Authenticated recent-solves event log' })
|
||||
async eventLog(
|
||||
@Query(new ZodValidationPipe(EventLogQuerySchema)) q: { limit?: number },
|
||||
): Promise<EventLogRowDto[]> {
|
||||
return this.svc.getEventLog(this.dataSource.manager, q.limit ?? 50);
|
||||
}
|
||||
|
||||
@Get('graph')
|
||||
@ApiOperation({ summary: 'Authenticated score graph (top 10 players)' })
|
||||
async graph(): Promise<GraphViewDto> {
|
||||
return this.svc.getGraph(this.dataSource.manager);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user