File size: 1,577 Bytes
3d23b0f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { FastifyRequest, FastifyReply } from 'fastify';
import * as service from './service';
import type { UserQuery, ContestQuery } from './types';

export async function getUserRatingHandler(
    request: FastifyRequest<{ Querystring: UserQuery }>,
    reply: FastifyReply
) {
    const { username } = request.query;
    const data = await service.getUserRating(username);
    return reply.send(data);
}

export async function getUserHistoryHandler(
    request: FastifyRequest<{ Querystring: UserQuery }>,
    reply: FastifyReply
) {
    const { username } = request.query;
    const data = await service.getUserHistory(username);
    return reply.send(data);
}

export async function getContestStandingsHandler(
    request: FastifyRequest<{ Querystring: ContestQuery & { extended?: boolean } }>,
    reply: FastifyReply
) {
    const { contestId, extended } = request.query;
    const data = await service.getContestStandings(contestId, extended);
    return reply.send(data);
}

export async function getContestResultsHandler(
    request: FastifyRequest<{ Querystring: ContestQuery }>,
    reply: FastifyReply
) {
    const { contestId } = request.query;
    const data = await service.getContestResults(contestId);
    return reply.send(data);
}

export async function getVirtualStandingsHandler(
    request: FastifyRequest<{ Querystring: ContestQuery & { showGhost?: boolean } }>,
    reply: FastifyReply
) {
    const { contestId, showGhost } = request.query;
    const data = await service.getVirtualStandings(contestId, showGhost);
    return reply.send(data);
}