kopia lustrzana https://gitlab.com/tomaszg/geostat
Owned caches: average finds per cache per day
rodzic
ef334790f4
commit
5e7a4a8a4b
|
@ -84,6 +84,8 @@ void Cache::set_date_hidden(const std::tm& t) {
|
|||
|
||||
std::strftime(tmp, 20, "%F", &date_hidden_tm);
|
||||
date_hidden = tmp;
|
||||
|
||||
age_now = (std::time(nullptr) - date_hidden_t) / (60 * 60 * 24);
|
||||
}
|
||||
|
||||
float cache_distance(const Cache& a, const Cache& b) {
|
||||
|
|
1
cache.h
1
cache.h
|
@ -83,6 +83,7 @@ public:
|
|||
std::string date;
|
||||
std::string date_hidden;
|
||||
int age_when_found = -1;
|
||||
int age_now = -1;
|
||||
|
||||
void set_date(const std::tm& t);
|
||||
void set_date_hidden(const std::tm& t);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
#include <unistd.h>
|
||||
|
||||
void show_usage() {
|
||||
|
@ -787,6 +788,8 @@ int main(int argc, char** argv) {
|
|||
std::cout << "Number of caches created: <span class=\"value\">" << cc.size() << "</span><br>\n";
|
||||
std::cout << "Number of caches that are disabled: <span class=\"value\">" << std::count_if(cc.begin(), cc.end(), [&](auto& a) { return a.status == disabled; }) << "</span><br>\n";
|
||||
std::cout << "Number of caches that are archived: <span class=\"value\">" << std::count_if(cc.begin(), cc.end(), [&](auto& a) { return a.status == archived; }) << "</span><br>\n";
|
||||
std::cout << "Average finds per cache per day: <span class=\"value\">" << std::setprecision(3) << std::accumulate(cc.begin(), cc.end(), 0., [&](const float& a, const Cache& b) { return std::move(a) + 1.0 * b.founds / b.age_now; }) / cc.size() << "</span><br>\n";
|
||||
std::cout << std::resetiosflags(std::cout.flags());
|
||||
std::cout << "</div>\n";
|
||||
|
||||
short y_min = std::min_element(cc.begin(), cc.end(), [&](const Cache& a, const Cache& b) { return a.date_hidden_tm.tm_year < b.date_hidden_tm.tm_year; })->date_hidden_tm.tm_year;
|
||||
|
|
Ładowanie…
Reference in New Issue