Skip to content

Commit 077624b

Browse files
authored
Fix stats route (ovidiuch#82)
1 parent f284278 commit 077624b

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

server/api.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,18 @@ export function addRoutes(app: express$Application) {
3737
}
3838
});
3939

40-
app.get('/stats', async (req: express$Request, res: express$Response) => {
41-
try {
42-
res.json({
43-
days: await getDailyStats()
44-
});
45-
} catch (err) {
46-
res.sendStatus(500);
40+
app.get(
41+
'/daily-stats',
42+
async (req: express$Request, res: express$Response) => {
43+
try {
44+
res.json({
45+
days: await getDailyStats()
46+
});
47+
} catch (err) {
48+
res.sendStatus(500);
49+
}
4750
}
48-
});
51+
);
4952

5053
app.get('/game/:gameId', (req: express$Request, res: express$Response) => {
5154
const gameId = req.params.gameId;

web/pages/stats.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import React, { Component } from 'react';
44
import withRedux from 'next-redux-wrapper';
55
import { createStore } from '../store';
6-
import { addCurUserToState, getStats } from '../utils/api';
6+
import { addCurUserToState, getDailyStats } from '../utils/api';
77
import Layout from '../components/Layout';
88

99
import type { DailyStats } from 'shared/types/state';
@@ -19,7 +19,7 @@ class StatsPage extends Component<Props> {
1919
await addCurUserToState(req, store);
2020
}
2121

22-
const { days } = await getStats();
22+
const { days } = await getDailyStats();
2323
return { days };
2424
}
2525

web/utils/api.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ export async function backfillGameActions(
6363
return fetchPost(`/backfill`, req);
6464
}
6565

66-
export async function getStats(): Promise<DailyStats> {
67-
return fetchJson(`/stats`);
66+
export async function getDailyStats(): Promise<DailyStats> {
67+
return fetchJson(`/daily-stats`);
6868
}
6969

7070
export function getApiUrl(path?: string) {

0 commit comments

Comments
 (0)