kopia lustrzana https://gitlab.com/tomaszg/geostat
Add some more data to powertrails table
rodzic
30d38d8fc4
commit
d4d8011be1
|
@ -324,7 +324,7 @@ void header_html() {
|
|||
std::cout << "<html lang=\"en\">\n";
|
||||
std::cout << " <head>\n";
|
||||
std::cout << " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n";
|
||||
std::cout << " <link rel=\"stylesheet\" type=\"text/css\" href=\"geo.css?ver=15\">\n";
|
||||
std::cout << " <link rel=\"stylesheet\" type=\"text/css\" href=\"geo.css?ver=16\">\n";
|
||||
std::cout << " <title>Geocaching stats</title>\n";
|
||||
std::cout << "</head>\n";
|
||||
std::cout << "<body>\n";
|
||||
|
|
8
geo.css
8
geo.css
|
@ -125,6 +125,14 @@ table.list {
|
|||
padding-right: 10px;
|
||||
}
|
||||
|
||||
.list td.bad {
|
||||
background-color: #ffaaaa;
|
||||
}
|
||||
|
||||
.list td.good {
|
||||
background-color: #aaffaa;
|
||||
}
|
||||
|
||||
.dt td {
|
||||
background: #DDD;
|
||||
color: #000;
|
||||
|
|
33
geostat.cpp
33
geostat.cpp
|
@ -203,15 +203,20 @@ int main(int argc, char** argv) {
|
|||
if (tc.data.count(c.code) > 0) {
|
||||
c.trail = tc.data[c.code];
|
||||
t.data[c.trail].found++;
|
||||
if (c.status == ok)
|
||||
t.data[c.trail].active_caches_not_found--;
|
||||
tt_map[c.trail] = &(t.data[c.trail]);
|
||||
}
|
||||
}
|
||||
for (const auto& i : tt_map) {
|
||||
if (i.second->found * 100 >= i.second->caches.size() * i.second->treshold_perc )
|
||||
i.second->completed_perc = (100 * i.second->found / i.second->caches.size());
|
||||
if (i.second->found >= i.second->treshold )
|
||||
i.second->completed = 1;
|
||||
else
|
||||
i.second->needed = i.second->treshold - i.second->found;
|
||||
tt.push_back(i.second);
|
||||
}
|
||||
std::sort(tt.begin(), tt.end(), [&](const auto& a, const auto& b) { return 1.0 * a->found / a->caches.size() > 1.0 * b->found / b->caches.size(); });
|
||||
std::sort(tt.begin(), tt.end(), [&](const auto& a, const auto& b) { return a->completed_perc > b->completed_perc; });
|
||||
|
||||
OCpl.get_ftf(uid, tmp);
|
||||
|
||||
|
@ -910,23 +915,33 @@ int main(int argc, char** argv) {
|
|||
std::cout << "<table class=\"list\">\n";
|
||||
std::cout << "<tr><th></th>";
|
||||
std::cout << "<th>Trail</th>";
|
||||
// std::cout << "<th>Type</th>";
|
||||
std::cout << "<th>Type</th>";
|
||||
std::cout << "<th>Caches</th>";
|
||||
std::cout << "<th>Found</th>";
|
||||
std::cout << "<th>Treshold</th>";
|
||||
std::cout << "<th>Needed</th>";
|
||||
std::cout << "<th>Available</th>";
|
||||
std::cout << "</tr>\n";
|
||||
|
||||
for (auto& i : tt) {
|
||||
if (i->completed)
|
||||
std::cout << "<tr class=\"highlight\">";
|
||||
else
|
||||
std::cout << "<tr>";
|
||||
std::cout << "<tr>";
|
||||
std::cout << "<th>" << n << "</th> ";
|
||||
std::cout << "<td>" << i->link_name() << "</td>";
|
||||
// std::cout << "<td>" << i->type << "</td>";
|
||||
std::cout << "<td>" << i->get_type() << "</td>";
|
||||
std::cout << "<td>" << i->caches.size() << "</td>";
|
||||
std::cout << "<td>" << i->found << "</td>";
|
||||
std::cout << "<td>" << (100 * i->found / i->caches.size()) << "% / " << i->treshold_perc << "%</td>";
|
||||
if (i->completed)
|
||||
std::cout << "<td class=\"good\">";
|
||||
else if (i->active_caches_not_found < i->needed)
|
||||
std::cout << "<td class=\"bad\">";
|
||||
else
|
||||
std::cout << "<td>";
|
||||
std::cout << i->completed_perc << "% / " << i->treshold_perc << "%</td>";
|
||||
std::cout << "<td>";
|
||||
if (!i->completed)
|
||||
std::cout << i->needed;
|
||||
std::cout << "</td>";
|
||||
std::cout << "<td>" << i->active_caches_not_found << "</td>";
|
||||
std::cout << "</tr>\n";
|
||||
n++;
|
||||
// if (n > LIST_MAX) break;
|
||||
|
|
|
@ -33,7 +33,11 @@ public:
|
|||
uint active_caches = 0;
|
||||
|
||||
uint found = 0;
|
||||
uint completed_perc;
|
||||
bool completed = 0;
|
||||
uint needed = 0;
|
||||
|
||||
uint active_caches_not_found = 0;
|
||||
|
||||
std::string link() const;
|
||||
std::string link_name() const;
|
||||
|
|
|
@ -12,7 +12,7 @@ using json = nlohmann::json;
|
|||
// }
|
||||
|
||||
int main() {
|
||||
Debug::set_debug_level(5);
|
||||
// Debug::set_debug_level(5);
|
||||
PowertrailDB T;
|
||||
|
||||
for (int i = 1; i < 1675; i++)
|
||||
|
|
Ładowanie…
Reference in New Issue