Commit 3d94f2cd authored by j.hoerdt's avatar j.hoerdt
Browse files

calculate first/last msg from all Measurements

closed #10
parent ea7730f9
......@@ -68,7 +68,7 @@ class Sensor {
);
add_attribute(body,
"21.T11148/22c62082a4d2d9ae2602",
"[{\"Date\":{\"date\":\"" + rec.get("measurement.first_msg").asLocalDate().toString() + "\",\"dateType\":\"first measurement\"}},{\"Date\":{\"date\":\"" + rec.get("measurement.last_msg").asLocalDate().toString() + "\",\"dateType\":\"last measurement\"}}]"
"[{\"Date\":{\"date\":\"" + rec.get("min(all_measurements.first_msg)").asLocalDate().toString() + "\",\"dateType\":\"first measurement\"}},{\"Date\":{\"date\":\"" + rec.get("max(all_measurements.last_msg)").asLocalDate().toString() + "\",\"dateType\":\"last measurement\"}}]"
);
add_attribute(body,
"21.T11148/709a23220f2c3d64d1e1",
......@@ -128,7 +128,7 @@ class Sensor {
"merge (s)-[:MEASURED_AT]->(measurement:MeasurementLocation {coordinates: $coordinates})" +
"merge (s)-[:IS_LOCATED]->(environment)" +
"merge (s)-[:HAS_MOBILITY]->(mobility)" +
string_if_exists.apply("country", "merge (measurement)-[:IN]->(country)") +
string_if_exists.apply("state", "merge (measurement)-[:IN]->(state)") +
string_if_exists.apply("city", "merge (measurement)-[:IN]->(city)") +
......@@ -136,7 +136,10 @@ class Sensor {
"set" +
" measurement.first_msg = case when date_ > measurement.first_msg then measurement.first_msg else date_ end," +
" measurement.last_msg = case when date_ < measurement.last_msg then measurement.last_msg else date_ end " +
"return distinct s.pid, id(s), measurement.first_msg, measurement.last_msg, type.sensor_type"
"with s, type.sensor_type as sensor_type\n" +
"match (s)--(all_measurements:MeasurementLocation)" +
"return s.pid, id(s), sensor_type, min(all_measurements.first_msg), max(all_measurements.last_msg)"
).withParameters(properties);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment