diff options
Diffstat (limited to 'apps/sm-db-select.h')
-rw-r--r-- | apps/sm-db-select.h | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/apps/sm-db-select.h b/apps/sm-db-select.h index fcbe91b..78678c5 100644 --- a/apps/sm-db-select.h +++ b/apps/sm-db-select.h @@ -7,13 +7,12 @@ namespace trygvis { namespace apps { -template<class T> +template <class T> using o = boost::optional<T>; using namespace std; using json = nlohmann::json; class sm_db_select : public app { - public: sm_db_select() : app("sm-db-select") { } @@ -39,8 +38,8 @@ public: auto deviceId = rs.begin()["id"].as<int>(); - rs = work.parameterized("select id from soil_moisture_sensor where device=$1 and sensor=$2")(deviceId)( - sensor).exec(); + rs = work.parameterized("select id from soil_moisture_sensor where device=$1 and sensor=$2")(deviceId)(sensor) + .exec(); if (!rs.size()) { cout << "Unknown sensor: " << sensor << endl; @@ -49,11 +48,11 @@ public: auto sensorId = rs.begin()["id"].as<int>(); - rs = work.parameterized("select timestamp, sensor, value from soil_moisture_sample where sensor=$1")( - sensorId).exec(); + rs = work.parameterized("select timestamp, sensor, value from soil_moisture_sample where sensor=$1")(sensorId) + .exec(); json points = json::array(); - for (auto sample: rs) { + for (auto sample : rs) { json s; s.push_back(sample["timestamp"].as<unsigned long>()); s.push_back(sample["sensor"].as<unsigned long>()); @@ -74,8 +73,6 @@ public: return EXIT_SUCCESS; } - }; - } } |