insert missing sensor readings
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 16 Jul 2023 07:01:11 +0000 (09:01 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 16 Jul 2023 07:01:11 +0000 (09:01 +0200)
parse-node-logs.pl

index 2e76c76..7e0d4ad 100755 (executable)
@@ -60,3 +60,17 @@ foreach my $filename (
        }
 }
 
+# insert missing sensor readings
+$dbh->do( qq{
+
+create temporary table nl_received as select _id,json->'received' as received from nodelog where json->'received' is not null;
+
+create temporary table eg_received as select _id,json->'received' as received from eg5120 where json->'received' is not null;
+
+create temporary table nl_new as select * from nl_received where received not in (select received from eg_received) ;
+
+select to_timestamp((json->>'received')::int8/1000), time,mac,addr,"nodeId",json,_id,sensor_type from nodelog where _id in (select _id from nl_new);
+
+insert into eg5120 select to_timestamp((json->>'received')::int8/1000) as time,mac,addr,"nodeId",json,sensor_type from nodelog where _id in (select _id from nl_new);
+
+} );