FIX: #60
This commit is contained in:
parent
e57f315dcb
commit
2b1263ec4a
|
@ -1,3 +1,4 @@
|
|||
from datetime import datetime
|
||||
from prometheus_client import CollectorRegistry, Counter, Gauge
|
||||
|
||||
from exporter.client_details import ClientDetails
|
||||
|
@ -48,9 +49,9 @@ class Metrics:
|
|||
def db_operation(cur, conn):
|
||||
cur.execute("""
|
||||
UPDATE node_details
|
||||
SET latitude = %s, longitude = %s, altitude = %s, precision = %s
|
||||
SET latitude = %s, longitude = %s, altitude = %s, precision = %s, updated_at = %s
|
||||
WHERE node_id = %s
|
||||
""", (latitude, longitude, altitude, precision, client_details.node_id))
|
||||
""", (latitude, longitude, altitude, precision, datetime.now().isoformat(), client_details.node_id))
|
||||
conn.commit()
|
||||
|
||||
self.db.execute_db_operation(db_operation)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import os
|
||||
from abc import ABC, abstractmethod
|
||||
from datetime import datetime
|
||||
from venv import logger
|
||||
|
||||
import psycopg
|
||||
|
@ -151,12 +152,13 @@ class NodeInfoAppProcessor(Processor):
|
|||
update_values.append(ClientDetails.get_role_name_from_role(user.role))
|
||||
|
||||
if update_fields:
|
||||
update_fields.append("updated_at = %s")
|
||||
update_query = f"""
|
||||
UPDATE node_details
|
||||
SET {", ".join(update_fields)}
|
||||
WHERE node_id = %s
|
||||
"""
|
||||
cur.execute(update_query, update_values + [client_details.node_id])
|
||||
cur.execute(update_query, update_values + [datetime.now().isoformat(), client_details.node_id])
|
||||
else:
|
||||
# If record doesn't exist, insert a new one
|
||||
cur.execute("""
|
||||
|
|
Loading…
Reference in a new issue