Add countries histogram

master
Tomasz Golinski 2021-09-05 19:44:44 +02:00
rodzic dc1bcdb009
commit 47f7edf3bc
4 zmienionych plików z 7 dodań i 3 usunięć

Wyświetl plik

@ -64,6 +64,7 @@ public:
float rating = 0;
bool recommended = 0; // was the cache recommended by that user?
std::string type;
std::string country;
std::string region;
std::string subregion;
std::string origin;

Wyświetl plik

@ -522,6 +522,7 @@ int main(int argc, char** argv) {
show_histogram(cc, &Cache::size, "Cache sizes", 1);
// show_histogram(fcc, &Cache::region, "Regions", 1);
// show_histogram(fcc, &Cache::subregion, "Subregions", 1);
show_histogram(fcc, &Cache::country, "Countries", 1);
show_nested_histogram(fcc, &Cache::region, &Cache::subregion, "Regions", 1);
show_histogram(cc, &Cache::day_of_week, "Days of the week", 1, 0);
show_histogram(cc, &Cache::mon, "Months", 1, 0);

Wyświetl plik

@ -360,7 +360,7 @@ Caches OCdb::get_user_caches(const std::string& uuid, __attribute__((unused)) in
int res;
//code TEXT PRIMARY KEY, name TEXT, location TEXT, type TEXT, status INTEGER, size TEXT, difficulty INTEGER, terrain INTEGER, country TEXT, region TEXT, owner TEXT)
sql = "SELECT code, location, type, size, difficulty, terrain, country, region, owner, status, name FROM caches WHERE EXISTS (SELECT cache_code FROM logs WHERE cache_code = code AND type = ";
sql = "SELECT code, location, type, size, difficulty, terrain, country, region, owner, status, name, country FROM caches WHERE EXISTS (SELECT cache_code FROM logs WHERE cache_code = code AND type = ";
sql += std::to_string(found);
sql += " and user = ?);";
@ -378,7 +378,7 @@ Caches OCdb::get_user_caches_owned(const std::string& uuid) const {
int res;
//code TEXT PRIMARY KEY, name TEXT, location TEXT, type TEXT, status TEXT, size TEXT, difficulty INTEGER, terrain INTEGER, country TEXT, region TEXT, owner TEXT)
sql = "SELECT code, location, type, size, difficulty, terrain, country, region, owner, status, name FROM caches WHERE owner = ?;";
sql = "SELECT code, location, type, size, difficulty, terrain, country, region, owner, status, name, country FROM caches WHERE owner = ?;";
res = sqlite3_prepare_v2(db, sql.c_str(), sql.length() + 1, &stmt, NULL);
if (res != SQLITE_OK) {
@ -409,6 +409,7 @@ Caches OCdb::parse_sql_caches() const {
if (sqlite3_column_text(stmt, 9)) c.status = static_cast<Status>(sqlite3_column_int(stmt, 9));
else c.status = unknown;
if (sqlite3_column_text(stmt, 10)) c.name = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 10));
if (sqlite3_column_text(stmt, 11)) c.country = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 11));
cc.push_back(c);
res = sqlite3_step(stmt);

Wyświetl plik

@ -93,7 +93,7 @@ void Okapi::get_user_caches_json(const std::string& uuid, int count, int offset)
void Okapi::get_caches_json(const std::string& codes) const {
std::string service = url + OKAPI_caches;
std::string query = "consumer_key=" + key + "&cache_codes=" + codes + "&fields=code|name|location|type|status|difficulty|terrain|owner|region|size2|date_created|recommendations|rating|founds|status";
std::string query = "consumer_key=" + key + "&cache_codes=" + codes + "&fields=code|name|location|type|status|difficulty|terrain|owner|region|country2|size2|date_created|recommendations|rating|founds|status";
curl_post(service, query);
}
@ -157,6 +157,7 @@ Caches Okapi::get_caches(const std::set<std::string>& codes) const {
c.type = el.value()["type"];
c.size = el.value()["size2"];
c.region = el.value()["region"];
c.country = el.value()["country2"];
c.diff = el.value()["difficulty"];
c.terr = el.value()["terrain"];
c.owner = el.value()["owner"]["username"];