kopia lustrzana https://gitlab.com/tomaszg/geostat
Add per row completion percentage to some tables
rodzic
6e959ea058
commit
dc1bcdb009
34
geostat.cpp
34
geostat.cpp
|
@ -768,9 +768,10 @@ int main(int argc, char** argv) {
|
|||
for (int j = 1; j <= 31; j++) { // print table day headers
|
||||
std::cout << "<th>" << j << "</th>";
|
||||
}
|
||||
std::cout << "</tr>\n";
|
||||
std::cout << "<th></th></tr>\n";
|
||||
|
||||
for (int i = 1; i <= 12; i++) { // i -> months in rows
|
||||
int m = 0;
|
||||
std::cout << "<tr><th>" << i << "</th> ";
|
||||
for (int j = 1; j <= 31; j++) { // j -> days in cols
|
||||
count = count_caches(cc, codes, [i, j](const Cache& c) -> bool { return (c.date_tm.tm_mon == i - 1 && c.date_tm.tm_mday == j); });
|
||||
|
@ -782,8 +783,24 @@ int main(int argc, char** argv) {
|
|||
} else {
|
||||
std::cout << "<td codes=\"" << codes << "\">" << count << "</td>";
|
||||
n++;
|
||||
m++;
|
||||
}
|
||||
}
|
||||
float perc;
|
||||
switch(i) {
|
||||
case 4:
|
||||
case 6:
|
||||
case 9:
|
||||
case 11:
|
||||
perc = m * 100.0 / 30;
|
||||
break;
|
||||
case 2:
|
||||
perc = m * 100.0 / 29;
|
||||
break;
|
||||
default:
|
||||
perc = m * 100.0 / 31;
|
||||
}
|
||||
std::cout << "<th>" << perc << "%</th>";
|
||||
std::cout << "</tr>\n";
|
||||
}
|
||||
std::cout << "</table>\n";
|
||||
|
@ -804,9 +821,13 @@ int main(int argc, char** argv) {
|
|||
for (int j = 1; j <= 12; j++) { // print table month headers
|
||||
std::cout << "<th>" << j << "</th>";
|
||||
}
|
||||
std::cout << "</tr>\n";
|
||||
std::cout << "<th></th></tr>\n";
|
||||
|
||||
std::time_t now = std::time(nullptr);
|
||||
std::tm* now_tm = std::localtime(&now);
|
||||
|
||||
for (int i = y_min; i <= y_max; i++) { // i -> years in rows
|
||||
int m = 0;
|
||||
std::cout << "<tr><th>" << i + 1900 << "</th> ";
|
||||
for (int j = 1; j <= 12; j++) { // j -> months in cols
|
||||
count = count_caches(cc, codes, [i, j](const Cache& c) -> bool { return (c.date_hidden_tm.tm_year == i && c.date_hidden_tm.tm_mon == j - 1); });
|
||||
|
@ -820,14 +841,19 @@ int main(int argc, char** argv) {
|
|||
else {
|
||||
std::cout << "<td codes=\"" << codes << "\">" << count << "</td>";
|
||||
n++;
|
||||
m++;
|
||||
}
|
||||
}
|
||||
if (now_tm) {
|
||||
if (i == now_tm->tm_year)
|
||||
std::cout << "<th>" << m * 100.0 / (now_tm->tm_mon + 1) << "%</th>";
|
||||
else
|
||||
std::cout << "<th>" << m * 100.0 / 12 << "%</th>";
|
||||
}
|
||||
std::cout << "</tr>\n";
|
||||
}
|
||||
std::cout << "</table>\n";
|
||||
|
||||
std::time_t now = std::time(nullptr);
|
||||
std::tm* now_tm = std::localtime(&now);
|
||||
if (now_tm) {
|
||||
if (!ocpl_user_uuid.empty() && ocde_user_uuid.empty()) {
|
||||
int m_count = (now_tm->tm_year - 106 - 1) * 12 + 8 + now_tm->tm_mon + 1; // 106 corresponds to 2006, 8 is no. of months since may till dec, +1 since tm_mon starts at 0
|
||||
|
|
Ładowanie…
Reference in New Issue