Dashboard: Show last sync date/time instead of just checkmark

- Queries server_sync_log for most recent successful sync
- Displays date (e.g., 'Apr 8') and time (e.g., '3:28 AM')
- Shows yellow dash with 'Never' if no syncs recorded

Chronicler #69
This commit is contained in:
Claude
2026-04-08 08:32:28 +00:00
parent 7f990933df
commit 7d21b4290a
2 changed files with 22 additions and 3 deletions

View File

@@ -42,11 +42,20 @@ router.get('/dashboard', async (req, res) => {
const activeSubscribers = parseInt(subStats[0]?.active_count || 0); const activeSubscribers = parseInt(subStats[0]?.active_count || 0);
const totalMRR = parseFloat(subStats[0]?.mrr || 0); const totalMRR = parseFloat(subStats[0]?.mrr || 0);
// Fetch most recent successful sync time
const { rows: syncRows } = await db.query(`
SELECT MAX(last_successful_sync) as last_sync
FROM server_sync_log
WHERE is_online = true
`);
const lastSyncTime = syncRows[0]?.last_sync || null;
res.render('admin/dashboard', { res.render('admin/dashboard', {
title: 'Command Bridge', title: 'Command Bridge',
serversOnline, serversOnline,
activeSubscribers, activeSubscribers,
totalMRR totalMRR,
lastSyncTime
}); });
} catch (error) { } catch (error) {
console.error('Dashboard data fetch error:', error); console.error('Dashboard data fetch error:', error);
@@ -55,7 +64,8 @@ router.get('/dashboard', async (req, res) => {
title: 'Command Bridge', title: 'Command Bridge',
serversOnline: 0, serversOnline: 0,
activeSubscribers: 0, activeSubscribers: 0,
totalMRR: 0 totalMRR: 0,
lastSyncTime: null
}); });
} }
}); });

View File

@@ -13,7 +13,16 @@
</div> </div>
<div class="bg-white dark:bg-darkcard rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 p-6"> <div class="bg-white dark:bg-darkcard rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 p-6">
<div class="text-sm text-gray-500 dark:text-gray-400">Last Sync</div> <div class="text-sm text-gray-500 dark:text-gray-400">Last Sync</div>
<div class="text-3xl font-bold mt-2 text-green-500">✓</div> <% if (lastSyncTime) { %>
<div class="text-xl font-bold mt-2 text-green-500">✓</div>
<div class="text-xs text-gray-500 dark:text-gray-400 mt-1">
<%= new Date(lastSyncTime).toLocaleDateString('en-US', { month: 'short', day: 'numeric' }) %>
<%= new Date(lastSyncTime).toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit', hour12: true }) %>
</div>
<% } else { %>
<div class="text-xl font-bold mt-2 text-yellow-500">—</div>
<div class="text-xs text-gray-500 dark:text-gray-400 mt-1">Never</div>
<% } %>
</div> </div>
</div> </div>