mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-04-04 01:01:35 -07:00
TEST: field locking test fixes 4
Signed-off-by: jokob-sk <jokob.sk@gmail.com>
This commit is contained in:
@@ -68,6 +68,27 @@ def ip_test_db():
|
|||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Add the View logic provided
|
||||||
|
cur.execute("""
|
||||||
|
CREATE VIEW LatestDeviceScan AS
|
||||||
|
WITH RankedScans AS (
|
||||||
|
SELECT
|
||||||
|
c.*,
|
||||||
|
ROW_NUMBER() OVER (
|
||||||
|
PARTITION BY c.scanMac, c.scanSourcePlugin
|
||||||
|
ORDER BY c.scanLastConnection DESC
|
||||||
|
) AS rn
|
||||||
|
FROM CurrentScan c
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
d.*,
|
||||||
|
r.*
|
||||||
|
FROM Devices d
|
||||||
|
LEFT JOIN RankedScans r
|
||||||
|
ON d.devMac = r.scanMac
|
||||||
|
WHERE r.rn = 1;
|
||||||
|
""")
|
||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
yield conn
|
yield conn
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|||||||
@@ -59,6 +59,27 @@ def in_memory_db():
|
|||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Add the View logic provided
|
||||||
|
cur.execute("""
|
||||||
|
CREATE VIEW LatestDeviceScan AS
|
||||||
|
WITH RankedScans AS (
|
||||||
|
SELECT
|
||||||
|
c.*,
|
||||||
|
ROW_NUMBER() OVER (
|
||||||
|
PARTITION BY c.scanMac, c.scanSourcePlugin
|
||||||
|
ORDER BY c.scanLastConnection DESC
|
||||||
|
) AS rn
|
||||||
|
FROM CurrentScan c
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
d.*,
|
||||||
|
r.*
|
||||||
|
FROM Devices d
|
||||||
|
LEFT JOIN RankedScans r
|
||||||
|
ON d.devMac = r.scanMac
|
||||||
|
WHERE r.rn = 1;
|
||||||
|
""")
|
||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
yield conn
|
yield conn
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user