From 776c06122af9b7f8f57eb903c7cd7c33d6f0effc Mon Sep 17 00:00:00 2001 From: Stefan Pranger Date: Thu, 23 Dec 2021 22:37:12 +0100 Subject: [PATCH] fetch alarms now alerts with dummy notifcation --- db/fetch_alarms.h | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/db/fetch_alarms.h b/db/fetch_alarms.h index 6a29d6a..0580793 100644 --- a/db/fetch_alarms.h +++ b/db/fetch_alarms.h @@ -2,28 +2,23 @@ #include #include +#include +#include namespace db { void fetch_alarms(sql::Database *db, uint32_t interval) { std::time_t now = std::time(nullptr); - stmt::Statement select_alarms = stmt::Statement::select().columns("dtstart, summary, description").from_table("alarms").inner_join("events", "events.rowid = alarms.eventID").where("dtstart?").close(); - DEBUG << select_alarms.str(); + stmt::Statement select_alarms = stmt::Statement::select().columns("absolute_trigger, summary, description").from_table("alarms").inner_join("events", "events.id = alarms.event_id").where("absolute_trigger > " + std::to_string(now) + " AND absolute_trigger < " + std::to_string(now + interval)).close(); try { sql::Statement query(*db, select_alarms.str()); - query.bind(1, now + interval); - query.bind(2, now); - DEBUG << query.getExpandedSQL(); - while (query.executeStep()) - { - uint32_t dtstart = query.getColumn(0); + while (query.executeStep()) { + uint32_t absolute_trigger = query.getColumn(0); std::string summary = query.getColumn(1); std::string description = query.getColumn(2); - DEBUG << dtstart << ", " << summary << ", " << description; + util::notify(description, summary + std::to_string(absolute_trigger - now)); } - } - catch (std::exception& e) - { + } catch (std::exception& e) { std::cout << "Exception: " << e.what() << std::endl; } }