build view count total

This commit is contained in:
2026-03-28 22:12:53 -05:00
parent 98e5a5a740
commit b08e9523e4
4 changed files with 44 additions and 3 deletions

View File

@@ -36,6 +36,20 @@ export async function adminRoutes(app: FastifyInstance) {
return { total: pending.length, indexed: done, no_text_found: failed };
});
/**
* GET /api/admin/stats
* Aggregate share and view counts across all memes.
*/
app.get('/api/admin/stats', { preHandler: requireAuth }, async () => {
const row = db
.prepare('SELECT SUM(share_count) as total_shares, SUM(view_count) as total_views FROM memes')
.get() as { total_shares: number | null; total_views: number | null };
return {
total_shares: row.total_shares ?? 0,
total_views: row.total_views ?? 0,
};
});
/**
* GET /api/admin/reindex/status
* Returns how many memes still need OCR indexing.