aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/sm-db-insert.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/apps/sm-db-insert.cpp b/apps/sm-db-insert.cpp
index 57a633c..46a64e2 100644
--- a/apps/sm-db-insert.cpp
+++ b/apps/sm-db-insert.cpp
@@ -1,7 +1,7 @@
#include <boost/lexical_cast.hpp>
+#include <pqxx/result_iterator.hxx>
#include <pqxx/connection.hxx>
#include <pqxx/transaction.hxx>
-#include <pqxx/result_iterator.hxx>
#include <json.hpp>
#include "apps.h"
#include <fstream>
@@ -16,7 +16,7 @@ class sm_db_insert : public app {
public:
sm_db_insert() : app("sm-db-insert") {}
- ~sm_db_insert() = default;
+ ~sm_db_insert() override = default;
void add_options(po::options_description_easy_init &options) override {
options("file", po::value<string>()->required(), "The file to read");
@@ -41,7 +41,7 @@ public:
auto select_device = "select id from soil_moisture_device where mac=$1";
auto rs = work.parameterized(select_device)(mac).exec();
- if (!rs.size()) {
+ if (rs.empty()) {
cout << "New device: " << mac << endl;
auto insert_device = "insert into soil_moisture_device(mac) values($1) returning id";
@@ -55,7 +55,7 @@ public:
auto select_sensor = "select id from soil_moisture_sensor where device=$1 and sensor=$2";
rs = work.parameterized(select_sensor)(deviceId)(sensor).exec();
- if (!rs.size()) {
+ if (rs.empty()) {
cout << "New sensor: " << sensor << endl;
auto insert_sensor = "insert into soil_moisture_sensor(device, sensor) values($1, $2) returning id";
@@ -63,8 +63,8 @@ public:
}
auto sensorId = rs.begin()["id"].as<int>();
- unsigned long timestamp = get<unsigned long>(j, "timestamp");
- unsigned int value = get<unsigned int>(j, "value");
+ auto timestamp = get<unsigned long>(j, "timestamp");
+ auto value = get<unsigned int>(j, "value");
auto insert_sample = "insert into soil_moisture_sample(sensor, timestamp, value) values($1, $2, $3)";
work.parameterized(insert_sample)(sensorId)(timestamp)(value).exec();