37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
|
|
import { Controller, Get, Query, Request, UseGuards } from '@nestjs/common';
|
||
|
|
import { JwtAuthGuard } from '../../auth/guards/jwt-auth.guard';
|
||
|
|
import { RequirePermission } from '../../auth/decorators/require-permission.decorator';
|
||
|
|
import { AnalyticsService } from './analytics.service';
|
||
|
|
|
||
|
|
@Controller('analytics')
|
||
|
|
@UseGuards(JwtAuthGuard)
|
||
|
|
export class AnalyticsController {
|
||
|
|
constructor(private readonly analyticsService: AnalyticsService) {}
|
||
|
|
|
||
|
|
@Get('overview')
|
||
|
|
@RequirePermission('contest:read')
|
||
|
|
getOverview(
|
||
|
|
@Request() req,
|
||
|
|
@Query('timeRange') timeRange?: string,
|
||
|
|
@Query('contestId') contestId?: string,
|
||
|
|
) {
|
||
|
|
const tenantId = req.tenantId || req.user?.tenantId;
|
||
|
|
return this.analyticsService.getOverview(tenantId, {
|
||
|
|
timeRange,
|
||
|
|
contestId: contestId ? parseInt(contestId) : undefined,
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
@Get('review')
|
||
|
|
@RequirePermission('contest:read')
|
||
|
|
getReviewAnalysis(
|
||
|
|
@Request() req,
|
||
|
|
@Query('contestId') contestId?: string,
|
||
|
|
) {
|
||
|
|
const tenantId = req.tenantId || req.user?.tenantId;
|
||
|
|
return this.analyticsService.getReviewAnalysis(tenantId, {
|
||
|
|
contestId: contestId ? parseInt(contestId) : undefined,
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|