mirror of
https://github.com/l5yth/potato-mesh.git
synced 2026-08-09 10:22:52 +02:00
Ensure last_heard never precedes position time (#31)
This commit is contained in:
+9
-1
@@ -37,6 +37,14 @@ def upsert_node(node_id, n):
|
||||
met = _get(n, "deviceMetrics") or {}
|
||||
pos = _get(n, "position") or {}
|
||||
lh = _get(n, "lastHeard")
|
||||
pt = _get(pos, "time")
|
||||
now = int(time.time())
|
||||
if lh is not None and lh > now:
|
||||
lh = now
|
||||
if pt is not None and pt > now:
|
||||
pt = now
|
||||
if pt is not None and (lh is None or lh < pt):
|
||||
lh = pt
|
||||
row = (
|
||||
node_id,
|
||||
_get(n, "num"),
|
||||
@@ -57,7 +65,7 @@ def upsert_node(node_id, n):
|
||||
_get(met, "channelUtilization"),
|
||||
_get(met, "airUtilTx"),
|
||||
_get(met, "uptimeSeconds"),
|
||||
_get(pos, "time"),
|
||||
pt,
|
||||
_get(pos, "locationSource"),
|
||||
_get(pos, "latitude"),
|
||||
_get(pos, "longitude"),
|
||||
|
||||
+6
-1
@@ -45,6 +45,11 @@ def upsert_node(db, node_id, n)
|
||||
pos = n["position"] || {}
|
||||
role = user["role"] || "CLIENT"
|
||||
lh = n["lastHeard"]
|
||||
pt = pos["time"]
|
||||
now = Time.now.to_i
|
||||
lh = now if lh && lh > now
|
||||
pt = now if pt && pt > now
|
||||
lh = pt if pt && (!lh || lh < pt)
|
||||
row = [
|
||||
node_id,
|
||||
n["num"],
|
||||
@@ -65,7 +70,7 @@ def upsert_node(db, node_id, n)
|
||||
met["channelUtilization"],
|
||||
met["airUtilTx"],
|
||||
met["uptimeSeconds"],
|
||||
pos["time"],
|
||||
pt,
|
||||
pos["locationSource"],
|
||||
pos["latitude"],
|
||||
pos["longitude"],
|
||||
|
||||
Reference in New Issue
Block a user