From 7eb76498b01357f2ef20f20d7d7361d37a97c7ea Mon Sep 17 00:00:00 2001 From: User Date: Sun, 1 Feb 2026 03:43:34 +0100 Subject: [PATCH] fix: don't update updated_at on device observations The updated_at timestamp should only change when user metadata changes (floor, label, position, notes), not on every scan observation. This was breaking peer sync because observation timestamps were overwriting metadata timestamps. Co-Authored-By: Claude Opus 4.5 --- src/rf_mapper/database.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/rf_mapper/database.py b/src/rf_mapper/database.py index 262a3f7..4993801 100644 --- a/src/rf_mapper/database.py +++ b/src/rf_mapper/database.py @@ -267,7 +267,7 @@ class DeviceDatabase: cursor = conn.cursor() timestamp = datetime.now().isoformat() - # Insert or update device + # Insert or update device (don't touch updated_at - that's for metadata changes only) cursor.execute(""" INSERT INTO devices (device_id, device_type, name, ssid, manufacturer, encryption, channel, frequency, first_seen, last_seen, total_observations) VALUES (?, 'wifi', ?, ?, ?, ?, ?, ?, ?, ?, 1) @@ -279,8 +279,7 @@ class DeviceDatabase: channel = COALESCE(excluded.channel, devices.channel), frequency = COALESCE(excluded.frequency, devices.frequency), last_seen = excluded.last_seen, - total_observations = devices.total_observations + 1, - updated_at = CURRENT_TIMESTAMP + total_observations = devices.total_observations + 1 """, (bssid, ssid, ssid, manufacturer, encryption, channel, frequency, timestamp, timestamp)) # Insert RSSI observation @@ -326,7 +325,7 @@ class DeviceDatabase: """, (address,)) prev = cursor.fetchone() - # Insert or update device + # Insert or update device (don't touch updated_at - that's for metadata changes only) cursor.execute(""" INSERT INTO devices (device_id, device_type, name, manufacturer, device_class, bt_device_type, first_seen, last_seen, total_observations) VALUES (?, 'bluetooth', ?, ?, ?, ?, ?, ?, 1) @@ -336,8 +335,7 @@ class DeviceDatabase: device_class = COALESCE(excluded.device_class, devices.device_class), bt_device_type = COALESCE(excluded.bt_device_type, devices.bt_device_type), last_seen = excluded.last_seen, - total_observations = devices.total_observations + 1, - updated_at = CURRENT_TIMESTAMP + total_observations = devices.total_observations + 1 """, (address, name, manufacturer, device_class, device_type, timestamp, timestamp)) # Insert RSSI observation