diff --git a/cache.h b/cache.h index d2cd8ee..8e4d081 100644 --- a/cache.h +++ b/cache.h @@ -53,6 +53,7 @@ public: float terr = 0; int fav = 0; int founds = 0; + bool recommended = 0; // was the cache recommended by that user? std::string type; std::string region; std::string origin; diff --git a/okapi.cpp b/okapi.cpp index 31c1dba..14cbfbb 100644 --- a/okapi.cpp +++ b/okapi.cpp @@ -78,7 +78,7 @@ std::string Okapi::curl_post(const std::string& url, const std::string& post) co std::string Okapi::get_user_caches_json(const std::string& uuid, int count, int offset) const { std::string service = url + OKAPI_logs; - std::string query = "consumer_key=" + key + "&user_uuid=" + uuid + "&fields=cache_code|type|date&limit=" + std::to_string(count) + "&offset=" + std::to_string(offset); + std::string query = "consumer_key=" + key + "&user_uuid=" + uuid + "&fields=cache_code|type|date|was_recommended&limit=" + std::to_string(count) + "&offset=" + std::to_string(offset); return curl_post(service, query); } @@ -173,6 +173,7 @@ Caches Okapi::get_user_caches(const std::string& uuid, int count) const { struct extra_data { std::tm date; + bool was_recommended; }; std::map tmp_data; // holds data from logs which needs to be added to Caches later @@ -191,7 +192,7 @@ Caches Okapi::get_user_caches(const std::string& uuid, int count) const { // TODO need to take care of the time zone :/ ss >> std::get_time(&date, "%Y-%m-%dT%H:%M:%S+"); codes.push_back(el.value()["cache_code"].get()); - tmp_data[el.value()["cache_code"].get()] = { date }; + tmp_data[el.value()["cache_code"].get()] = { date, el.value()["was_recommended"] }; } } off += j.size(); @@ -207,7 +208,7 @@ Caches Okapi::get_user_caches(const std::string& uuid, int count) const { std::stringstream ss(el.value()["date"].get()); ss >> std::get_time(&date, "%Y-%m-%dT%H-%M-%S"); codes.push_back(el.value()["cache_code"].get()); - tmp_data[el.value()["cache_code"].get()] = { date }; + tmp_data[el.value()["cache_code"].get()] = { date, el.value()["was_recommended"] }; } } off += j.size(); @@ -225,6 +226,7 @@ Caches Okapi::get_user_caches(const std::string& uuid, int count) const { for (auto& el : tmp_data) { auto& it = mcc.at(el.first); it.set_date(el.second.date); + it.recommended = el.second.was_recommended; } return cc;