diff --git a/cache.h b/cache.h index 2a76a46..0047297 100644 --- a/cache.h +++ b/cache.h @@ -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; diff --git a/geostat.cpp b/geostat.cpp index 1c60b5b..c45f380 100644 --- a/geostat.cpp +++ b/geostat.cpp @@ -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); diff --git a/ocdb.cpp b/ocdb.cpp index b82daf7..7f9a1fa 100644 --- a/ocdb.cpp +++ b/ocdb.cpp @@ -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(sqlite3_column_int(stmt, 9)); else c.status = unknown; if (sqlite3_column_text(stmt, 10)) c.name = reinterpret_cast(sqlite3_column_text(stmt, 10)); + if (sqlite3_column_text(stmt, 11)) c.country = reinterpret_cast(sqlite3_column_text(stmt, 11)); cc.push_back(c); res = sqlite3_step(stmt); diff --git a/okapi.cpp b/okapi.cpp index 585efd2..1f2e8ce 100644 --- a/okapi.cpp +++ b/okapi.cpp @@ -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& 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"];