Reorder stats on the page

sql-rework
Tomasz Golinski 2020-05-03 23:14:37 +02:00
rodzic f136a4df12
commit ba8efbda97
1 zmienionych plików z 78 dodań i 78 usunięć

Wyświetl plik

@ -391,14 +391,6 @@ int main(int argc, char** argv) {
std::cout << "Average distance between caches: <span class=\"value\">" << tot_dist / (sorted_fcaches.size() - 1) << "</span> km<br>\n";
std::cout << "</div>\n";
auto N = *std::max_element(fcc.begin(), fcc.end(), [&](const Cache* a, const Cache* b) { return a->pos.lat < b->pos.lat; });
auto S = *std::min_element(fcc.begin(), fcc.end(), [&](const Cache* a, const Cache* b) { return a->pos.lat < b->pos.lat; });
auto E = *std::max_element(fcc.begin(), fcc.end(), [&](const Cache* a, const Cache* b) { return a->pos.lon < b->pos.lon; });
auto W = *std::min_element(fcc.begin(), fcc.end(), [&](const Cache* a, const Cache* b) { return a->pos.lon < b->pos.lon; });
short y_min = std::min_element(cc.begin(), cc.end(), [&](const Cache& a, const Cache& b) { return a.date_tm.tm_year < b.date_tm.tm_year; })->date_tm.tm_year;
short y_max = std::max_element(cc.begin(), cc.end(), [&](const Cache& a, const Cache& b) { return a.date_tm.tm_year < b.date_tm.tm_year; })->date_tm.tm_year;
std::cout << "<h2>Caching timeline</h2>\n";
std::cout << "<table class=\"calendar_tab\">\n";
std::cout << "<tr><th></th>";
@ -407,6 +399,9 @@ int main(int argc, char** argv) {
}
std::cout << "</tr>\n";
short y_min = std::min_element(cc.begin(), cc.end(), [&](const Cache& a, const Cache& b) { return a.date_tm.tm_year < b.date_tm.tm_year; })->date_tm.tm_year;
short y_max = std::max_element(cc.begin(), cc.end(), [&](const Cache& a, const Cache& b) { return a.date_tm.tm_year < b.date_tm.tm_year; })->date_tm.tm_year;
long max = 0; // maximal value for histogram
for (int i = y_min; i <= y_max; i++)
for (int j = 1; j <= 12; j++)
@ -422,19 +417,6 @@ int main(int argc, char** argv) {
}
std::cout << "</table>\n";
std::cout << "<h2>Geographically extreme caches</h2>\n";
std::cout << "<table class=\"list\">\n";
std::cout << "<tr>\n";
std::cout << " <th>North:</th><td>" << N->link_name() << "</td><td>" << N->pos.lat << "</td>\n";
std::cout << "</tr><tr>\n";
std::cout << " <th>South:</th><td>" << S->link_name() << "</td><td>" << S->pos.lat << "</td>\n";
std::cout << "</tr><tr>\n";
std::cout << " <th>East:</th> <td>" << E->link_name() << "</td><td>" << E->pos.lon << "</td>\n";
std::cout << "</tr><tr>\n";
std::cout << " <th>West:</th> <td>" << W->link_name() << "</td><td>" << W->pos.lon << "</td>\n";
std::cout << "</tr>\n";
std::cout << "</table>\n";
// auto far = std::max_element(fcc.begin(), fcc.end(), [&](const Cache& a, const Cache& b) { return a.distance() < b.distance(); });
// auto near = std::min_element(fcc.begin(), fcc.end(), [&](const Cache& a, const Cache& b) { return a.distance() < b.distance(); });
//
@ -457,66 +439,24 @@ int main(int argc, char** argv) {
// DT matrix
n = 0;
std::cout << "<h2>Difficulty / terrain matrix</h2>\n";
std::cout << "<table class=\"dt\">\n";
std::cout << "<tr><th></th>";
for (int j = 2; j <= 10; j++) { // print table terr headers
std::cout << "<th>" << j / 2.0 << "</th>";
}
auto N = *std::max_element(fcc.begin(), fcc.end(), [&](const Cache* a, const Cache* b) { return a->pos.lat < b->pos.lat; });
auto S = *std::min_element(fcc.begin(), fcc.end(), [&](const Cache* a, const Cache* b) { return a->pos.lat < b->pos.lat; });
auto E = *std::max_element(fcc.begin(), fcc.end(), [&](const Cache* a, const Cache* b) { return a->pos.lon < b->pos.lon; });
auto W = *std::min_element(fcc.begin(), fcc.end(), [&](const Cache* a, const Cache* b) { return a->pos.lon < b->pos.lon; });
std::cout << "<h2>Geographically extreme caches</h2>\n";
std::cout << "<table class=\"list\">\n";
std::cout << "<tr>\n";
std::cout << " <th>North:</th><td>" << N->link_name() << "</td><td>" << N->pos.lat << "</td>\n";
std::cout << "</tr><tr>\n";
std::cout << " <th>South:</th><td>" << S->link_name() << "</td><td>" << S->pos.lat << "</td>\n";
std::cout << "</tr><tr>\n";
std::cout << " <th>East:</th> <td>" << E->link_name() << "</td><td>" << E->pos.lon << "</td>\n";
std::cout << "</tr><tr>\n";
std::cout << " <th>West:</th> <td>" << W->link_name() << "</td><td>" << W->pos.lon << "</td>\n";
std::cout << "</tr>\n";
for (int i = 2; i <= 10; i++) { // i -> diff in rows
std::cout << "<tr><th>" << i / 2.0 << "</th> ";
for (int j = 2; j <= 10; j++) { // j -> terr in cols
count = std::count_if(cc.begin(), cc.end(), [i, j](Cache c) { return (c.diff == i / 2.0 && c.terr == j / 2.0); });
if (count == 0)
std::cout << "<td class=\"dt_zero\">" << 0 << "</td>";
else {
std::cout << "<td>" << count << "</td>";
n++;
}
}
std::cout << "</tr>\n";
}
std::cout << "</table>\n";
std::cout << "<div class=\"basic_stats\">\n";
std::cout << "Total <span class=\"value\">" << n << "</span> combinations found out of 81 (" << std::setprecision(3) << n / 0.81 << "%).\n";
std::cout << "</div>\n";
// Days matrix
n = 0;
std::cout << "<h2>Caching days matrix</h2>\n";
std::cout << "<table class=\"dt\">\n";
std::cout << "<tr><th></th>";
for (int j = 1; j <= 31; j++) { // print table day headers
std::cout << "<th>" << j << "</th>";
}
std::cout << "</tr>\n";
for (int i = 1; i <= 12; i++) { // i -> months in rows
std::cout << "<tr><th>" << i << "</th> ";
for (int j = 1; j <= 31; j++) { // j -> days in cols
count = std::count_if(cc.begin(), cc.end(), [i, j](Cache c) { return (c.date_tm.tm_mon == i - 1 && c.date_tm.tm_mday == j); });
if (count == 0) {
if ((j == 31 && (i == 2 || i == 4 || i == 6 || i == 9 || i == 11)) || (j == 30 && i == 2))
std::cout << "<td class=\"dt_null\"></td>";
else
std::cout << "<td class=\"dt_zero\">" << 0 << "</td>";
} else {
std::cout << "<td>" << count << "</td>";
n++;
}
}
std::cout << "</tr>\n";
}
std::cout << "</table>\n";
std::cout << "<div class=\"basic_stats\">\n";
std::cout << "Total <span class=\"value\">" << n << "</span> days out of 366 (" << std::setprecision(3) << n / 3.66 << "%).\n";
std::cout << "</div>\n";
const int LIST_MAX = 15;
n = 1;
@ -660,6 +600,66 @@ int main(int argc, char** argv) {
}
std::cout << "</table>\n";
std::cout << "<h2>Difficulty / terrain matrix</h2>\n";
std::cout << "<table class=\"dt\">\n";
std::cout << "<tr><th></th>";
for (int j = 2; j <= 10; j++) { // print table terr headers
std::cout << "<th>" << j / 2.0 << "</th>";
}
std::cout << "</tr>\n";
for (int i = 2; i <= 10; i++) { // i -> diff in rows
std::cout << "<tr><th>" << i / 2.0 << "</th> ";
for (int j = 2; j <= 10; j++) { // j -> terr in cols
count = std::count_if(cc.begin(), cc.end(), [i, j](Cache c) { return (c.diff == i / 2.0 && c.terr == j / 2.0); });
if (count == 0)
std::cout << "<td class=\"dt_zero\">" << 0 << "</td>";
else {
std::cout << "<td>" << count << "</td>";
n++;
}
}
std::cout << "</tr>\n";
}
std::cout << "</table>\n";
std::cout << "<div class=\"basic_stats\">\n";
std::cout << "Total <span class=\"value\">" << n << "</span> combinations found out of 81 (" << std::setprecision(3) << n / 0.81 << "%).\n";
std::cout << "</div>\n";
// Days matrix
n = 0;
std::cout << "<h2>Caching days matrix</h2>\n";
std::cout << "<table class=\"dt\">\n";
std::cout << "<tr><th></th>";
for (int j = 1; j <= 31; j++) { // print table day headers
std::cout << "<th>" << j << "</th>";
}
std::cout << "</tr>\n";
for (int i = 1; i <= 12; i++) { // i -> months in rows
std::cout << "<tr><th>" << i << "</th> ";
for (int j = 1; j <= 31; j++) { // j -> days in cols
count = std::count_if(cc.begin(), cc.end(), [i, j](Cache c) { return (c.date_tm.tm_mon == i - 1 && c.date_tm.tm_mday == j); });
if (count == 0) {
if ((j == 31 && (i == 2 || i == 4 || i == 6 || i == 9 || i == 11)) || (j == 30 && i == 2))
std::cout << "<td class=\"dt_null\"></td>";
else
std::cout << "<td class=\"dt_zero\">" << 0 << "</td>";
} else {
std::cout << "<td>" << count << "</td>";
n++;
}
}
std::cout << "</tr>\n";
}
std::cout << "</table>\n";
std::cout << "<div class=\"basic_stats\">\n";
std::cout << "Total <span class=\"value\">" << n << "</span> days out of 366 (" << std::setprecision(3) << n / 3.66 << "%).\n";
std::cout << "</div>\n";
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;
y_max = std::max_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;