build view count total
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user