mirror of
https://github.com/l5yth/potato-mesh.git
synced 2026-03-28 17:42:48 +01:00
sort chat nodes by first seen field in database
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user