From 918fb99b87c17300cdef2a38d88fc2b4c3995cf3 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 10 Apr 2026 22:23:21 +0000 Subject: [PATCH] Add Social Overview card to Trinity Console dashboard - Shows cross-platform totals (posts, views, likes, comments) - Breaks down by platform with icons - Clickable link to full Social Analytics page Chronicler #76 --- services/arbiter-3.0/src/routes/admin.js | 37 ++++++++++++- .../arbiter-3.0/src/views/admin/dashboard.ejs | 52 +++++++++++++++++++ 2 files changed, 88 insertions(+), 1 deletion(-) diff --git a/services/arbiter-3.0/src/routes/admin.js b/services/arbiter-3.0/src/routes/admin.js index 63c7f44..20d0f60 100644 --- a/services/arbiter-3.0/src/routes/admin.js +++ b/services/arbiter-3.0/src/routes/admin.js @@ -15,12 +15,47 @@ const isAdmin = (req, res, next) => { router.get('/', isAdmin, async (req, res) => { try { const mappings = getRoleMappings(); + + // Fetch social stats across all platforms + const 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 + `); + + // Aggregate totals + const socialTotals = { + posts: 0, + views: 0, + likes: 0, + comments: 0, + platforms: {} + }; + + for (const row of socialStats.rows) { + 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: 'Dashboard', adminUser: req.user, csrfToken: req.csrfToken(), mappings: mappings, - currentPath: '/dashboard' + currentPath: '/dashboard', + socialTotals }); } catch (error) { console.error('Admin dashboard error:', error); diff --git a/services/arbiter-3.0/src/views/admin/dashboard.ejs b/services/arbiter-3.0/src/views/admin/dashboard.ejs index 0fd5492..b180aa0 100644 --- a/services/arbiter-3.0/src/views/admin/dashboard.ejs +++ b/services/arbiter-3.0/src/views/admin/dashboard.ejs @@ -55,6 +55,58 @@ + + <% if (socialTotals && socialTotals.posts > 0) { %> + +
+
+ 📊 +

Social Overview

+
+ Click for details → +
+
+
+
<%= socialTotals.posts %>
+
Total Posts
+
+
+
<%= socialTotals.views.toLocaleString() %>
+
Total Views
+
+
+
<%= socialTotals.likes.toLocaleString() %>
+
Total Likes
+
+
+
<%= socialTotals.comments %>
+
Comments
+
+
+ <% if (Object.keys(socialTotals.platforms).length > 0) { %> +
+ <% for (const [platform, stats] of Object.entries(socialTotals.platforms)) { %> +
+ <% if (platform === 'tiktok') { %> + 🎵 + <% } else if (platform === 'bluesky') { %> + 🦋 + <% } else if (platform === 'instagram') { %> + 📷 + <% } else if (platform === 'facebook') { %> + 📘 + <% } else if (platform === 'x') { %> + 𝕏 + <% } %> + <%= platform %> + (<%= stats.views.toLocaleString() %> views) +
+ <% } %> +
+ <% } %> +
+ <% } %> +

🔥❄️ Welcome to Trinity Console