kopia lustrzana https://gitlab.com/tomaszg/geostat
clang-format
rodzic
816c94049a
commit
48e43613d1
12
common.h
12
common.h
|
@ -45,11 +45,15 @@ uint find_streak(const Date_Caches& cc, std::time_t& start);
|
|||
|
||||
uint get_num(char c, char* opt);
|
||||
|
||||
template <typename T> void average_html(const Caches& cc, T Cache::*ptr, const std::string& caption);
|
||||
template <typename T> float average(const Caches& cc, T Cache::*ptr);
|
||||
template <typename T>
|
||||
void average_html(const Caches& cc, T Cache::*ptr, const std::string& caption);
|
||||
template <typename T>
|
||||
float average(const Caches& cc, T Cache::*ptr);
|
||||
|
||||
template <typename T> void sum_html(const Caches& cc, T Cache::*ptr, const std::string& caption);
|
||||
template <typename T> T sum(const Caches& cc, T Cache::*ptr);
|
||||
template <typename T>
|
||||
void sum_html(const Caches& cc, T Cache::*ptr, const std::string& caption);
|
||||
template <typename T>
|
||||
T sum(const Caches& cc, T Cache::*ptr);
|
||||
|
||||
int count_caches(const Caches& cc, std::string& codes, std::function<bool(const Cache& c)> test);
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@ Debug::Debug(int n) : lvl(n) {
|
|||
if (lvl > 1) indent.append("*** ");
|
||||
buffer << indent;
|
||||
|
||||
// std::time_t now = std::time(nullptr);
|
||||
// std::string dt = std::ctime(&now);
|
||||
// std::cout << dt << " ";
|
||||
// std::time_t now = std::time(nullptr);
|
||||
// std::string dt = std::ctime(&now);
|
||||
// std::cout << dt << " ";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ void show_usage() {
|
|||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
if (argc < 3) show_usage();
|
||||
|
||||
User user1, user2;
|
||||
|
@ -22,7 +21,7 @@ int main(int argc, char** argv) {
|
|||
user2.use_oc = true;
|
||||
user1.get_caches();
|
||||
user2.get_caches();
|
||||
|
||||
|
||||
int cc_no1 = user1.caches_hidden;
|
||||
int cc_no2 = user2.caches_hidden;
|
||||
|
||||
|
@ -56,7 +55,7 @@ int main(int argc, char** argv) {
|
|||
|
||||
std::cout << "</div>\n";
|
||||
|
||||
// const int LIST_MAX = 100;
|
||||
// const int LIST_MAX = 100;
|
||||
short int n = 1;
|
||||
|
||||
if (cc_no1 > 0) {
|
||||
|
@ -82,7 +81,7 @@ int main(int argc, char** argv) {
|
|||
std::cout << "<td>" << i->region << "</td>";
|
||||
std::cout << "</tr>\n";
|
||||
n++;
|
||||
// if (n > LIST_MAX) break;
|
||||
// if (n > LIST_MAX) break;
|
||||
}
|
||||
std::cout << "</table>\n";
|
||||
}
|
||||
|
@ -111,7 +110,7 @@ int main(int argc, char** argv) {
|
|||
std::cout << "<td>" << i->region << "</td>";
|
||||
std::cout << "</tr>\n";
|
||||
n++;
|
||||
// if (n > LIST_MAX) break;
|
||||
// if (n > LIST_MAX) break;
|
||||
}
|
||||
}
|
||||
std::cout << "</table>\n";
|
||||
|
|
|
@ -13,7 +13,6 @@ void show_usage() {
|
|||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
#include "config_user.h"
|
||||
|
||||
if (argc == 1) show_usage();
|
||||
|
@ -104,4 +103,3 @@ int main(int argc, char** argv) {
|
|||
|
||||
footer_html();
|
||||
}
|
||||
|
||||
|
|
25
geostat.cpp
25
geostat.cpp
|
@ -49,7 +49,6 @@ int main(int argc, char** argv) {
|
|||
|
||||
if (argc == 1) show_usage();
|
||||
|
||||
|
||||
int o;
|
||||
while ((o = getopt(argc, argv, "qNOQD:o::p:d:u:n:r:k:i:f:H:s:m:etah?")) != -1)
|
||||
switch (o) {
|
||||
|
@ -303,8 +302,8 @@ int main(int argc, char** argv) {
|
|||
show_histogram(user.cc, &Cache::owner, "Cache owners", 1);
|
||||
show_histogram(user.cc, &Cache::type, "Cache types", 1);
|
||||
show_histogram(user.cc, &Cache::size, "Cache sizes", 1);
|
||||
// show_histogram(fcc, &Cache::region, "Regions", 1);
|
||||
// show_histogram(fcc, &Cache::subregion, "Subregions", 1);
|
||||
// show_histogram(fcc, &Cache::region, "Regions", 1);
|
||||
// show_histogram(fcc, &Cache::subregion, "Subregions", 1);
|
||||
show_histogram(user.fcc, &Cache::country, "Countries", 1);
|
||||
show_nested_histogram(user.fcc, &Cache::region, &Cache::subregion, "Regions", 1);
|
||||
show_histogram(user.cc, &Cache::day_of_week, "Days of the week", 1, 0);
|
||||
|
@ -527,7 +526,7 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
std::cout << "</table>\n";
|
||||
|
||||
// D/T matrix
|
||||
// D/T matrix
|
||||
n = 0;
|
||||
|
||||
std::cout << "<h2>Difficulty / terrain matrix</h2>\n";
|
||||
|
@ -559,7 +558,7 @@ int main(int argc, char** argv) {
|
|||
std::cout << "Average terrain: <span class=\"value\">" << average(user.cc, &Cache::terr) << "</span><br>\n";
|
||||
std::cout << "</div>\n";
|
||||
|
||||
// Days matrix
|
||||
// Days matrix
|
||||
n = 0;
|
||||
|
||||
std::cout << "<h2>Caching days matrix</h2>\n";
|
||||
|
@ -609,7 +608,7 @@ int main(int argc, char** argv) {
|
|||
std::cout << "Total <span class=\"value\">" << n << "</span> days out of 366 (" << std::setprecision(3) << n / 3.66 << "%).\n";
|
||||
std::cout << "</div>\n";
|
||||
|
||||
// Hidden months matrix
|
||||
// Hidden months matrix
|
||||
n = 0;
|
||||
|
||||
y_min = std::min_element(user.cc.begin(), user.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;
|
||||
|
@ -697,20 +696,20 @@ int main(int argc, char** argv) {
|
|||
std::cout << "<td>";
|
||||
std::cout << i->completed_perc << "% / " << i->treshold_perc << "%</td>";
|
||||
std::cout << "<td>";
|
||||
if (!i->completed)
|
||||
std::cout << i->needed;
|
||||
if (!i->completed)
|
||||
std::cout << i->needed;
|
||||
std::cout << "</td>";
|
||||
std::cout << "<td>";
|
||||
if (i->active_caches_not_found && i->active_caches_not_found < UINT_MAX-1024)
|
||||
std::cout << i->active_caches_not_found;
|
||||
if (i->active_caches_not_found && i->active_caches_not_found < UINT_MAX - 1024)
|
||||
std::cout << i->active_caches_not_found;
|
||||
std::cout << "</td>";
|
||||
std::cout << "</tr>\n";
|
||||
n++;
|
||||
// if (n > LIST_MAX) break;
|
||||
// if (n > LIST_MAX) break;
|
||||
}
|
||||
std::cout << "</table>\n";
|
||||
|
||||
// show_histogram(tt, "Power trails (completion percentage)", 1);
|
||||
// show_histogram(tt, "Power trails (completion percentage)", 1);
|
||||
std::cout << "<div class=\"basic_stats\">\n";
|
||||
std::cout << "Number of completed power trails: <span class=\"value\">" << std::count_if(user.tt.begin(), user.tt.end(), [&](const auto& a) { return a->completed; }) << "</span><br>\n";
|
||||
std::cout << "Number of started power trails: <span class=\"value\">" << user.tt.size() << "</span><br>\n";
|
||||
|
@ -737,7 +736,7 @@ int main(int argc, char** argv) {
|
|||
std::cout << "<td>" << i->founds << "</td>";
|
||||
std::cout << "</tr>\n";
|
||||
n++;
|
||||
// if (n > LIST_MAX) break;
|
||||
// if (n > LIST_MAX) break;
|
||||
}
|
||||
std::cout << "</table>\n";
|
||||
std::cout << "<div class=\"basic_stats\">\n";
|
||||
|
|
|
@ -65,12 +65,12 @@ int main(int argc, char** argv) {
|
|||
int o;
|
||||
while ((o = getopt(argc, argv, "qNOg:o::p:d:u:n:r:k:MDCH:s:m:etaLTYh?")) != -1)
|
||||
switch (o) {
|
||||
// case 'd':
|
||||
// Debug::set_debug_level(get_num('d',optarg));
|
||||
// break;
|
||||
// case 'g':
|
||||
// gpx_file = optarg;
|
||||
break;
|
||||
// case 'd':
|
||||
// Debug::set_debug_level(get_num('d',optarg));
|
||||
// break;
|
||||
// case 'g':
|
||||
// gpx_file = optarg;
|
||||
break;
|
||||
case 'o':
|
||||
user.use_oc = 1;
|
||||
if (optarg) {
|
||||
|
@ -112,9 +112,9 @@ int main(int argc, char** argv) {
|
|||
case 'M':
|
||||
show_minmax = 1;
|
||||
break;
|
||||
// case 'D':
|
||||
// show_dist = 1;
|
||||
// break;
|
||||
// case 'D':
|
||||
// show_dist = 1;
|
||||
// break;
|
||||
case 'C':
|
||||
show_calendar = 1;
|
||||
break;
|
||||
|
@ -224,7 +224,7 @@ int main(int argc, char** argv) {
|
|||
// if (show_dist) {
|
||||
// auto far = *std::max_element(user.fcc.begin(), user.fcc.end(), [&](const Cache* a, const Cache* b) { return a->distance() < b->distance(); });
|
||||
// auto near = *std::min_element(user.fcc.begin(), user.fcc.end(), [&](const Cache* a, const Cache* b) { return a->distance() < b->distance(); });
|
||||
//
|
||||
//
|
||||
// std::cout << "Nearest cache: " << near->distance() << " km\n";
|
||||
// near->show();
|
||||
// std::cout << "Furthest cache: " << far->distance() << " km\n";
|
||||
|
|
12
okapi.cpp
12
okapi.cpp
|
@ -289,15 +289,15 @@ void Okapi::update_caches(Caches& cc) const {
|
|||
// void Okapi::update_caches_ratings(Caches& cc) const {
|
||||
// std::map<std::string, Cache*> pcc;
|
||||
// std::string code;
|
||||
//
|
||||
//
|
||||
// uint k;
|
||||
// std::string codes_list;
|
||||
// codes_list.reserve(MAX_CACHES * 8); // maximum of MAX_CACHES codes, 7 chars per code plus a separator
|
||||
//
|
||||
//
|
||||
// auto it = cc.begin();
|
||||
// while (it != cc.end()) {
|
||||
// k = 0;
|
||||
//
|
||||
//
|
||||
// while (it != cc.end() && k < MAX_CACHES) {
|
||||
// codes_list += it->code;
|
||||
// codes_list += '|';
|
||||
|
@ -306,16 +306,16 @@ void Okapi::update_caches(Caches& cc) const {
|
|||
// k++;
|
||||
// }
|
||||
// codes_list.pop_back(); // remove trailing '|'
|
||||
//
|
||||
//
|
||||
// get_caches_ratings_json(codes_list);
|
||||
// json j = json::parse(curl_output);
|
||||
// codes_list.clear();
|
||||
//
|
||||
//
|
||||
// for (auto& el : j.items()) {
|
||||
// code = el.value()["code"];
|
||||
// pcc[code]->fav = el.value()["recommendations"];
|
||||
// if (!el.value()["rating"].is_null()) pcc[code]->rating = el.value()["rating"];
|
||||
//
|
||||
//
|
||||
// if (el.value()["status"] == "Available")
|
||||
// pcc[code]->status = ok;
|
||||
// else if (el.value()["status"] == "Temporarily unavailable")
|
||||
|
|
2
okapi.h
2
okapi.h
|
@ -53,7 +53,7 @@ public:
|
|||
std::string get_changelog_json(int revision) const;
|
||||
|
||||
void update_caches(Caches& cc) const;
|
||||
// void update_caches_ratings(Caches& cc) const;
|
||||
// void update_caches_ratings(Caches& cc) const;
|
||||
std::string get_uuid(const std::string& username, uint* id = nullptr) const;
|
||||
std::string get_profile_url(const std::string& uuid) const;
|
||||
void get_ftf(uint uid, Caches& cc) 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 < 2000; i++)
|
||||
|
|
15
user.cpp
15
user.cpp
|
@ -5,7 +5,6 @@
|
|||
#include "debug.h"
|
||||
|
||||
void User::get_caches() {
|
||||
|
||||
if (use_oc) {
|
||||
if (!ocpl_user_uuid.empty() || !ocpl_user.empty()) {
|
||||
Okapi OCpl(ocpl);
|
||||
|
@ -29,7 +28,7 @@ void User::get_caches() {
|
|||
}
|
||||
for (const auto& i : tt_map) {
|
||||
i.second->completed_perc = (100 * i.second->found / i.second->caches.size());
|
||||
if (i.second->found >= i.second->treshold )
|
||||
if (i.second->found >= i.second->treshold)
|
||||
i.second->completed = 1;
|
||||
else
|
||||
i.second->needed = i.second->treshold - i.second->found;
|
||||
|
@ -80,11 +79,11 @@ void User::get_caches() {
|
|||
}
|
||||
}
|
||||
|
||||
// if (!gpx_file.empty()) {
|
||||
// GPX gpxfile(gpx_file);
|
||||
// Caches tmp = gpxfile.get_user_caches();
|
||||
// std::copy(tmp.begin(), tmp.end(), std::back_inserter(cc));
|
||||
// }
|
||||
// if (!gpx_file.empty()) {
|
||||
// GPX gpxfile(gpx_file);
|
||||
// Caches tmp = gpxfile.get_user_caches();
|
||||
// std::copy(tmp.begin(), tmp.end(), std::back_inserter(cc));
|
||||
// }
|
||||
|
||||
if (use_ocdb) {
|
||||
if (!ocpl_user_uuid.empty() || !ocpl_user.empty()) {
|
||||
|
@ -122,7 +121,7 @@ void User::get_caches() {
|
|||
Okapi OCde(ocde);
|
||||
OCde.update_caches(tmp);
|
||||
std::copy(tmp.begin(), tmp.end(), std::back_inserter(cc));
|
||||
// region_count = db.get_region_stats();
|
||||
// region_count = db.get_region_stats();
|
||||
} else if (get_owned) {
|
||||
Caches tmp = db.get_user_caches_owned(ocde_user_uuid);
|
||||
Okapi OCde(ocde);
|
||||
|
|
2
user.h
2
user.h
|
@ -36,7 +36,7 @@ public:
|
|||
std::string ocnl_user;
|
||||
std::string ocro_user;
|
||||
std::string ocuk_user;
|
||||
// std::string gpx_file;
|
||||
// std::string gpx_file;
|
||||
|
||||
bool get_not_found = 0;
|
||||
bool get_owned = 0;
|
||||
|
|
Ładowanie…
Reference in New Issue