Precompute treshold for powertrails, note rounding is always up

master
Tomasz Golinski 2022-07-18 19:39:13 +02:00
rodzic 6706ef9898
commit 30d38d8fc4
2 zmienionych plików z 5 dodań i 0 usunięć

Wyświetl plik

@ -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 });
}

Wyświetl plik

@ -27,6 +27,7 @@ public:
std::tm date;
std::string date_str;
uint treshold_perc;
uint treshold;
std::unordered_set<std::string> caches;
uint active_caches = 0;