sort chat nodes by first seen field in database

This commit is contained in:
l5y
2025-09-14 09:20:38 +02:00
parent b4600a26af
commit bcaa9dc1a9
2 changed files with 5 additions and 5 deletions

View File

@@ -14,9 +14,9 @@ def query_nodes(limit)
min_last_heard = Time.now.to_i - 7 * 24 * 60 * 60
rows = db.execute <<~SQL, [min_last_heard, limit]
SELECT node_id, short_name, long_name, hw_model, role, snr,
battery_level, voltage, last_heard, uptime_seconds,
channel_utilization, air_util_tx, position_time,
latitude, longitude, altitude
battery_level, voltage, last_heard, first_heard,
uptime_seconds, channel_utilization, air_util_tx,
position_time, latitude, longitude, altitude
FROM nodes
WHERE last_heard >= ?
ORDER BY last_heard DESC

View File

@@ -143,7 +143,7 @@
function addNewNodeChatEntry(n) {
const div = document.createElement('div');
const ts = formatDate(new Date(n.last_heard * 1000));
const ts = formatDate(new Date(n.first_heard * 1000));
div.className = 'chat-entry-node';
div.innerHTML = `[${ts}] ${n.node_id || ''} ${renderShortHtml(n.short_name || '')} <em>New node: ${n.long_name || ''}</em>`;
chatEl.appendChild(div);
@@ -294,7 +294,7 @@
seenNodeIds.add(n.node_id);
}
}
newNodes.sort((a, b) => (a.last_heard ?? 0) - (b.last_heard ?? 0));
newNodes.sort((a, b) => (a.first_heard ?? 0) - (b.first_heard ?? 0));
for (const n of newNodes) {
addNewNodeChatEntry(n);
}