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