stop devParentMAC overwrite if specified #1021

This commit is contained in:
jokob-sk
2025-03-23 15:12:07 +11:00
parent 8d9a4d23d1
commit 393904c91f
2 changed files with 10 additions and 6 deletions

View File

@@ -376,11 +376,15 @@ def update_devices_data_from_scan (db):
FROM CurrentScan FROM CurrentScan
WHERE Devices.devMac = CurrentScan.cur_MAC WHERE Devices.devMac = CurrentScan.cur_MAC
) )
WHERE EXISTS ( WHERE
SELECT 1 (devParentMAC IS NULL OR devParentMAC IN ("", "null", "(unknown)", "(Unknown)"))
FROM CurrentScan AND
WHERE Devices.devMac = CurrentScan.cur_MAC EXISTS (
AND CurrentScan.cur_NetworkNodeMAC IS NOT NULL AND CurrentScan.cur_NetworkNodeMAC NOT IN ("", "null") SELECT 1
FROM CurrentScan
WHERE Devices.devMac = CurrentScan.cur_MAC
AND CurrentScan.cur_NetworkNodeMAC IS NOT NULL AND CurrentScan.cur_NetworkNodeMAC NOT IN ("", "null")
)""") )""")
# Update only devices with empty or NULL devSite # Update only devices with empty or NULL devSite

View File

@@ -66,7 +66,7 @@ def process_scan (db):
# Clear current scan as processed # Clear current scan as processed
# 🐛 CurrentScan DEBUG: comment out below when debugging to keep the CurrentScan table after restarts/scan finishes # 🐛 CurrentScan DEBUG: comment out below when debugging to keep the CurrentScan table after restarts/scan finishes
db.sql.execute ("DELETE FROM CurrentScan") # db.sql.execute ("DELETE FROM CurrentScan")
# Commit changes # Commit changes
db.commitDB() db.commitDB()