kopia lustrzana https://gitlab.com/tomaszg/geostat
Fetch information if the cache was recommended by the user from Okapi
rodzic
1a3a7e0747
commit
fc98a0a858
1
cache.h
1
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;
|
||||
|
|
|
@ -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<std::string, extra_data> 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<std::string>());
|
||||
tmp_data[el.value()["cache_code"].get<std::string>()] = { date };
|
||||
tmp_data[el.value()["cache_code"].get<std::string>()] = { 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<std::string>());
|
||||
ss >> std::get_time(&date, "%Y-%m-%dT%H-%M-%S");
|
||||
codes.push_back(el.value()["cache_code"].get<std::string>());
|
||||
tmp_data[el.value()["cache_code"].get<std::string>()] = { date };
|
||||
tmp_data[el.value()["cache_code"].get<std::string>()] = { 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;
|
||||
|
|
Ładowanie…
Reference in New Issue