@cryptotaxi247 / netdata-1 / commits / 6d2fd8886

Handle cases where entries where stored as text (with strftime("%s")) (#13472)

Stelios Fragkakis committed Aug 2, 2022 at 18:12 UTC 6d2fd8886124fe64534636f2c1093bd19a06701b
1 file changed +4 -4
database/sqlite/sqlite_aclk.c
+4 -4
@@ -874,7 +874,7 @@ void sql_maint_aclk_sync_database(struct aclk_database_worker_config *wc, struct
874 BUFFER *sql = buffer_create(ACLK_SYNC_QUERY_SIZE);
875
876 buffer_sprintf(sql,"DELETE FROM aclk_chart_%s WHERE date_submitted IS NOT NULL AND "
877 - "date_updated < unixepoch()-%d;", wc->uuid_str, ACLK_DELETE_ACK_INTERNAL);
877 + "CAST(date_updated AS INT) < unixepoch()-%d;", wc->uuid_str, ACLK_DELETE_ACK_INTERNAL);
878 db_execute(buffer_tostring(sql));
879 buffer_flush(sql);
880
@@ -885,17 +885,17 @@ void sql_maint_aclk_sync_database(struct aclk_database_worker_config *wc, struct
885 buffer_flush(sql);
886
887 buffer_sprintf(sql,"DELETE FROM aclk_alert_%s WHERE date_submitted IS NOT NULL AND "
888 - "date_cloud_ack < unixepoch()-%d;", wc->uuid_str, ACLK_DELETE_ACK_ALERTS_INTERNAL);
888 + "CAST(date_cloud_ack AS INT) < unixepoch()-%d;", wc->uuid_str, ACLK_DELETE_ACK_ALERTS_INTERNAL);
889 db_execute(buffer_tostring(sql));
890 buffer_flush(sql);
891
892 buffer_sprintf(sql,"UPDATE aclk_chart_%s SET status = NULL, date_submitted=unixepoch() WHERE "
893 - "date_submitted IS NULL AND date_created < unixepoch()-%d;", wc->uuid_str, ACLK_AUTO_MARK_SUBMIT_INTERVAL);
893 + "date_submitted IS NULL AND CAST(date_created AS INT) < unixepoch()-%d;", wc->uuid_str, ACLK_AUTO_MARK_SUBMIT_INTERVAL);
894 db_execute(buffer_tostring(sql));
895 buffer_flush(sql);
896
897 buffer_sprintf(sql,"UPDATE aclk_chart_%s SET date_updated = unixepoch() WHERE date_updated IS NULL"
898 - " AND date_submitted IS NOT NULL AND date_submitted < unixepoch()-%d;",
898 + " AND date_submitted IS NOT NULL AND CAST(date_submitted AS INT) < unixepoch()-%d;",
899 wc->uuid_str, ACLK_AUTO_MARK_UPDATED_INTERVAL);
900 db_execute(buffer_tostring(sql));
901