|
|
|
|
@ -376,7 +376,18 @@ def checkdata():
|
|
|
|
|
conn = get_db_connection() # koneksi ke 192.168.1.85
|
|
|
|
|
cursor = conn.cursor()
|
|
|
|
|
current_timestamp = datetime.now()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Delete records from today before inserting new ones
|
|
|
|
|
today_date = current_timestamp.date()
|
|
|
|
|
delete_query = """
|
|
|
|
|
DELETE FROM _log_pi_status_data
|
|
|
|
|
WHERE DATE(latest_created_at) = %s
|
|
|
|
|
"""
|
|
|
|
|
cursor.execute(delete_query, (today_date,))
|
|
|
|
|
deleted_count = cursor.rowcount
|
|
|
|
|
conn.commit()
|
|
|
|
|
print(f"Deleted {deleted_count} records from _log_pi_status_data with latest_created_at={today_date}")
|
|
|
|
|
|
|
|
|
|
data_to_insert = []
|
|
|
|
|
for result in results:
|
|
|
|
|
# Only insert records with status other than "green"
|
|
|
|
|
|