diff --git a/powertrail.cpp b/powertrail.cpp index 7664e96..0fd9775 100644 --- a/powertrail.cpp +++ b/powertrail.cpp @@ -32,6 +32,8 @@ void from_json(const json& j, Powertrail& item) { j.at("caches").get_to(item.caches); j.at("type").get_to(item.type); strptime(item.date_str.c_str(), "%d-%m-%Y", &item.date); + item.treshold = (item.caches.size() * item.treshold_perc + 99) / 100; // Integer division rounding up + item.active_caches_not_found = item.active_caches; } std::string Powertrail::link() const { @@ -132,6 +134,8 @@ void PowertrailDB::get_trail(uint n) { T.active_caches++; } + T.treshold = (T.caches.size() * T.treshold_perc + 99) / 100; // Integer division rounding up + data.insert({ n, T }); } diff --git a/powertrail.h b/powertrail.h index 12acb0a..f4535f6 100644 --- a/powertrail.h +++ b/powertrail.h @@ -27,6 +27,7 @@ public: std::tm date; std::string date_str; uint treshold_perc; + uint treshold; std::unordered_set caches; uint active_caches = 0;