Skip to content

Commit

Permalink
fix 2 vendor overwrite #509🩹
Browse files Browse the repository at this point in the history
  • Loading branch information
jokob-sk committed Nov 22, 2023
1 parent a0a5410 commit 5ec13d8
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions pialert/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,17 +200,30 @@ def update_devices_data_from_scan (db):
WHERE NOT EXISTS (SELECT 1 FROM CurrentScan
WHERE dev_MAC = cur_MAC) """)

# Update IP & Vendor
mylog('debug', '[Update Devices] - 3 LastIP & Vendor')
# Update IP
mylog('debug', '[Update Devices] - 3 LastIP ')
sql.execute("""UPDATE Devices
SET dev_LastIP = (SELECT cur_IP FROM CurrentScan
WHERE dev_MAC = cur_MAC),
dev_Vendor = (SELECT cur_Vendor FROM CurrentScan
WHERE dev_MAC = cur_MAC
)
WHERE dev_MAC = cur_MAC)
WHERE EXISTS (SELECT 1 FROM CurrentScan
WHERE dev_MAC = cur_MAC) """)

# Update only devices with empty or NULL vendors
mylog('debug', '[Update Devices] - 3 Vendor')
sql.execute("""UPDATE Devices
SET dev_Vendor = (
SELECT cur_Vendor
FROM CurrentScan
WHERE dev_MAC = cur_MAC
)
WHERE
(dev_Vendor = "" OR dev_Vendor IS NULL)
AND EXISTS (
SELECT 1
FROM CurrentScan
WHERE dev_MAC = cur_MAC
)""")

# Update (unknown) or (name not found) Names if available
mylog('debug','[Update Devices] - 4 Unknown Name')
sql.execute ("""UPDATE Devices
Expand Down

0 comments on commit 5ec13d8

Please sign in to comment.