Fix /stats route: make async and correct trending mints response

- Make /stats route handler async
- Await getTrendingMints call
- Fix trending mints response to use view_count instead of views_7d
This commit is contained in:
Michilis
2025-12-21 01:49:05 -03:00
parent 62c9651a5e
commit 0db5dec5ec

View File

@@ -59,7 +59,7 @@ router.get('/health', (req, res) => {
* GET /stats
* System statistics
*/
router.get('/stats', (req, res) => {
router.get('/stats', async(req, res) => {
try {
// Mint counts by status
const mintCounts = countMintsByStatus();
@@ -102,7 +102,7 @@ router.get('/stats', (req, res) => {
const recentReviews = getRecentReviews(5);
// Trending mints
const trending = getTrendingMints(5);
const trending = await getTrendingMints(5);
res.json({
mints: {
@@ -121,7 +121,7 @@ router.get('/stats', (req, res) => {
trending_mints: trending.map(m => ({
mint_id: m.mint_id,
name: m.name,
views_7d: m.views_7d
views_7d: m.view_count
})),
computed_at: nowISO()
});