Fix: Add socialTotals to correct dashboard route file

Was editing wrong file (admin.js vs admin/index.js)

Chronicler #76
This commit is contained in:
Claude
2026-04-10 22:26:10 +00:00
parent 918fb99b87
commit 7c534b53a4

View File

@@ -53,12 +53,45 @@ router.get('/dashboard', async (req, res) => {
`);
const lastSyncTime = syncRows[0]?.last_sync || null;
// Fetch social stats across all platforms
const { rows: socialStats } = await db.query(`
SELECT
platform,
COUNT(*) as post_count,
COALESCE(SUM(views), 0) as total_views,
COALESCE(SUM(likes), 0) as total_likes,
COALESCE(SUM(comments), 0) as total_comments
FROM social_posts
GROUP BY platform
`);
const socialTotals = {
posts: 0,
views: 0,
likes: 0,
comments: 0,
platforms: {}
};
for (const row of socialStats) {
socialTotals.posts += parseInt(row.post_count);
socialTotals.views += parseInt(row.total_views);
socialTotals.likes += parseInt(row.total_likes);
socialTotals.comments += parseInt(row.total_comments);
socialTotals.platforms[row.platform] = {
posts: parseInt(row.post_count),
views: parseInt(row.total_views),
likes: parseInt(row.total_likes)
};
}
res.render('admin/dashboard', {
title: 'Command Bridge',
serversOnline,
activeSubscribers,
totalMRR,
lastSyncTime
lastSyncTime,
socialTotals
});
} catch (error) {
console.error('Dashboard data fetch error:', error);
@@ -68,7 +101,8 @@ router.get('/dashboard', async (req, res) => {
serversOnline: 0,
activeSubscribers: 0,
totalMRR: 0,
lastSyncTime: null
lastSyncTime: null,
socialTotals: { posts: 0, views: 0, likes: 0, comments: 0, platforms: {} }
});
}
});