From 49f8274f47612b000139778e9e4212b764b8535c Mon Sep 17 00:00:00 2001 From: cproudlock Date: Fri, 24 Oct 2025 10:01:55 -0400 Subject: [PATCH] Feature: Priority-based sorting and display limit optimization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Backend (server.js): - Implemented severity-based sorting for current events - Priority hierarchy: Incident > Change > Awareness > TBD - Events with same severity sorted by starttime (earliest first) - Upcoming events remain sorted by starttime only - Added severityPriority mapping for consistent ordering Frontend (index.html): - Reduced display limits for 1080p TVs: 2 current + 2 upcoming = 4 total - Prevents content overflow on 1080p displays - 4K displays still auto-scale content appropriately - Ensures critical incidents always appear first in current events Testing: - Verified Incident appears before Change before Awareness - Verified all 4 events fit on 1080p screen without scrolling 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- public/index.html | 6 ++++-- server.js | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/public/index.html b/public/index.html index 244d110..115b087 100644 --- a/public/index.html +++ b/public/index.html @@ -463,8 +463,10 @@ let html = ''; // Limit display to fit on TV screen without scrolling - const MAX_CURRENT = 3; - const MAX_UPCOMING = 3; + // 1080p: 2+2 = 4 events max + // 4K: Will scale up automatically via CSS + const MAX_CURRENT = 2; + const MAX_UPCOMING = 2; // Current Events (limit to MAX_CURRENT) if (data.current && data.current.length > 0) { diff --git a/server.js b/server.js index 7b29936..48fb692 100644 --- a/server.js +++ b/server.js @@ -59,6 +59,33 @@ app.get('/api/notifications', async (req, res) => { } }); + // Sort current events by severity priority, then by starttime + // Priority: Incident (danger) > Change (warning) > Awareness/TBD (success) + const severityPriority = { + 'danger': 1, // Incident - highest priority + 'warning': 2, // Change + 'success': 3, // Awareness/TBD - lowest priority + 'secondary': 4 // Fallback + }; + + currentEvents.sort((a, b) => { + const priorityA = severityPriority[a.typecolor] || 4; + const priorityB = severityPriority[b.typecolor] || 4; + + // First sort by priority + if (priorityA !== priorityB) { + return priorityA - priorityB; + } + + // If same priority, sort by starttime (earliest first) + return new Date(a.starttime) - new Date(b.starttime); + }); + + // Upcoming events stay sorted by starttime only + upcomingEvents.sort((a, b) => { + return new Date(a.starttime) - new Date(b.starttime); + }); + res.json({ success: true, timestamp: new Date().toISOString(),