aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/api/Stats.ts
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/api/Stats.ts')
-rw-r--r--frontend/src/api/Stats.ts52
1 files changed, 52 insertions, 0 deletions
diff --git a/frontend/src/api/Stats.ts b/frontend/src/api/Stats.ts
new file mode 100644
index 0000000..21654b5
--- /dev/null
+++ b/frontend/src/api/Stats.ts
@@ -0,0 +1,52 @@
1import axios from "axios";
2import { url } from "./Api";
3
4export interface PortalCountData {
5 date: string;
6 count: number;
7}
8
9export interface RecordsTimelineResponse {
10 timeline_singleplayer: PortalCountData[];
11 timeline_multiplayer: PortalCountData[];
12}
13
14export interface ScoreLog {
15 game: {
16 id: number;
17 name: string;
18 image: string;
19 is_coop: boolean;
20 category_portals: null;
21 };
22 user: {
23 steam_id: string;
24 user_name: string;
25 };
26 map: {
27 id: number;
28 name: string;
29 image: string;
30 is_disabled: boolean;
31 portal_count: number;
32 difficulty: number;
33 };
34 score_count: number;
35}
36
37export async function get_portal_count_history(): Promise<RecordsTimelineResponse | undefined> {
38 const response = await axios.get(url("stats/timeline"));
39 if (!response.data.data) {
40 return undefined;
41 }
42 return response.data.data;
43}
44
45export async function get_recent_scores(): Promise<ScoreLog[]> {
46 const response = await axios.get(url("stats/scores"));
47 if (!response.data.data) {
48 return [];
49 }
50 return response.data.data.scores.slice(0, 5);
51}
52