mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-04-15 14:41:38 -07:00
BE: TZ timestamp work #1251
Signed-off-by: jokob-sk <jokob.sk@gmail.com>
This commit is contained in:
@@ -223,13 +223,12 @@ class plugin_manager:
|
|||||||
sql.execute("""
|
sql.execute("""
|
||||||
SELECT MAX(DateTimeChanged) AS last_changed,
|
SELECT MAX(DateTimeChanged) AS last_changed,
|
||||||
COUNT(*) AS total_objects,
|
COUNT(*) AS total_objects,
|
||||||
SUM(CASE WHEN DateTimeCreated = DateTimeChanged THEN 1 ELSE 0 END) AS new_objects,
|
SUM(CASE WHEN DateTimeCreated = DateTimeChanged THEN 1 ELSE 0 END) AS new_objects
|
||||||
CURRENT_TIMESTAMP AS state_updated
|
|
||||||
FROM Plugins_Objects
|
FROM Plugins_Objects
|
||||||
WHERE Plugin = ?
|
WHERE Plugin = ?
|
||||||
""", (plugin_name,))
|
""", (plugin_name,))
|
||||||
row = sql.fetchone()
|
row = sql.fetchone()
|
||||||
last_changed, total_objects, new_objects, state_updated = row if row else ("", 0, 0, "")
|
last_changed, total_objects, new_objects, state_updated = row if row else ("", 0, 0)
|
||||||
new_objects = new_objects or 0 # ensure it's int
|
new_objects = new_objects or 0 # ensure it's int
|
||||||
changed_objects = total_objects - new_objects
|
changed_objects = total_objects - new_objects
|
||||||
|
|
||||||
@@ -238,7 +237,7 @@ class plugin_manager:
|
|||||||
"totalObjects": total_objects or 0,
|
"totalObjects": total_objects or 0,
|
||||||
"newObjects": new_objects or 0,
|
"newObjects": new_objects or 0,
|
||||||
"changedObjects": changed_objects or 0,
|
"changedObjects": changed_objects or 0,
|
||||||
"stateUpdated": state_updated or ""
|
"stateUpdated": timeNowTZ()
|
||||||
}
|
}
|
||||||
|
|
||||||
# Save in memory
|
# Save in memory
|
||||||
@@ -249,8 +248,7 @@ class plugin_manager:
|
|||||||
SELECT Plugin,
|
SELECT Plugin,
|
||||||
MAX(DateTimeChanged) AS last_changed,
|
MAX(DateTimeChanged) AS last_changed,
|
||||||
COUNT(*) AS total_objects,
|
COUNT(*) AS total_objects,
|
||||||
SUM(CASE WHEN DateTimeCreated = DateTimeChanged THEN 1 ELSE 0 END) AS new_objects,
|
SUM(CASE WHEN DateTimeCreated = DateTimeChanged THEN 1 ELSE 0 END) AS new_objects
|
||||||
CURRENT_TIMESTAMP AS state_updated
|
|
||||||
FROM Plugins_Objects
|
FROM Plugins_Objects
|
||||||
GROUP BY Plugin
|
GROUP BY Plugin
|
||||||
""")
|
""")
|
||||||
@@ -262,7 +260,7 @@ class plugin_manager:
|
|||||||
"totalObjects": total_objects or 0,
|
"totalObjects": total_objects or 0,
|
||||||
"newObjects": new_objects or 0,
|
"newObjects": new_objects or 0,
|
||||||
"changedObjects": changed_objects or 0,
|
"changedObjects": changed_objects or 0,
|
||||||
"stateUpdated": state_updated or ""
|
"stateUpdated": timeNowTZ()
|
||||||
}
|
}
|
||||||
|
|
||||||
# Save in memory
|
# Save in memory
|
||||||
|
|||||||
@@ -645,10 +645,7 @@ def update_devices_names(pm):
|
|||||||
|
|
||||||
# --- Step 3: Log last checked time ---
|
# --- Step 3: Log last checked time ---
|
||||||
# After resolving names, update last checked
|
# After resolving names, update last checked
|
||||||
sql = pm.db.sql
|
pm.name_plugins_checked = timeNowTZ()
|
||||||
sql.execute("SELECT CURRENT_TIMESTAMP")
|
|
||||||
row = sql.fetchone()
|
|
||||||
pm.name_plugins_checked = row[0] if row else None
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# Updates devPresentLastScan for parent devices based on the presence of their NICs
|
# Updates devPresentLastScan for parent devices based on the presence of their NICs
|
||||||
|
|||||||
Reference in New Issue
Block a user