source: Klonkt/src/routes/admin-stats.js@ 834bcc3

main
Last change on this file since 834bcc3 was 834bcc3, checked in by Robin Genis <roboburr@…>, 3 months ago

i18n: translate Dutch code comments to English across src/

Comments in routes/services/views/config/middleware/assets translated to
English for the public repo. A few dev-facing throw/console message strings
were Englished too. No user-facing UI strings or i18n dictionary values changed
(src/services/i18n.js untouched). Logic unchanged.

Co-Authored-By: Claude <noreply@…>

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/**
2 * Admin: Statistics (premium module, god-only).
3 *
4 * GET /admin/stats -> cookie-free statistics: visitors/views per day,
5 * plays, and the most popular posts/tracks.
6 *
7 * Premium-gated via premiumUnlocked() (premium layer off = freely available;
8 * on = Patreon required). Tracking is in StatsService (no cookies).
9 */
10
11import express from 'express';
12import db from '../config/database.js';
13import { renderPage } from '../middleware/render.js';
14import { requireGod } from '../middleware/auth.js';
15import { premiumUnlocked } from '../services/PatreonService.js';
16import { getStats } from '../services/StatsService.js';
17
18const router = express.Router();
19
20router.get('/', requireGod, (req, res) => {
21 if (!premiumUnlocked()) {
22 return res.status(403).send('Statistieken is een premium-functie — koppel Patreon in Beheer → Instellingen.');
23 }
24 // Link-in-bio clicks (premium #6) for the current site.
25 let linkClicks = [];
26 if (res.locals.site) {
27 try {
28 linkClicks = db.prepare(
29 'SELECT url, clicks FROM link_clicks WHERE site_id = ? AND clicks > 0 ORDER BY clicks DESC LIMIT 50'
30 ).all(res.locals.site.id);
31 } catch { linkClicks = []; }
32 }
33 const days = [7, 14, 30, 90].includes(parseInt(req.query.days, 10)) ? parseInt(req.query.days, 10) : 14;
34 renderPage(req, res, 'pages/admin-stats', {
35 pageTitle: 'Statistieken',
36 bodyClass: 'on-admin',
37 stats: getStats(days),
38 linkClicks,
39 });
40});
41
42export default router;
Note: See TracBrowser for help on using the repository browser.