Fix a bug reintroduced while changing the containers: need to use set for codes to get rid of duplicates

sql-rework
Tomasz Golinski 2020-02-29 23:05:11 +01:00
rodzic 93d05cb4ab
commit d961ae6dab
2 zmienionych plików z 5 dodań i 5 usunięć

Wyświetl plik

@ -117,7 +117,7 @@ std::string Okapi::get_caches_json(const std::string& codes) const {
// return c;
// }
Caches Okapi::get_caches(const std::vector<std::string>& codes) const {
Caches Okapi::get_caches(const std::set<std::string>& codes) const {
Cache c;
Caches cc;
@ -169,7 +169,7 @@ Caches Okapi::get_caches(const std::vector<std::string>& codes) const {
Caches Okapi::get_user_caches(const std::string& uuid, int count) const {
Caches cc;
std::vector<std::string> codes;
std::set<std::string> codes;
struct extra_data {
std::tm date;
@ -191,7 +191,7 @@ Caches Okapi::get_user_caches(const std::string& uuid, int count) const {
std::stringstream ss(el.value()["date"].get<std::string>());
// 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>());
codes.insert(el.value()["cache_code"].get<std::string>());
tmp_data[el.value()["cache_code"].get<std::string>()] = { date, el.value()["was_recommended"] };
}
}
@ -207,7 +207,7 @@ Caches Okapi::get_user_caches(const std::string& uuid, int count) const {
if (el.value()["type"] == "Found it") {
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>());
codes.insert(el.value()["cache_code"].get<std::string>());
tmp_data[el.value()["cache_code"].get<std::string>()] = { date, el.value()["was_recommended"] };
}
}

Wyświetl plik

@ -26,7 +26,7 @@ public:
Okapi(const std::string& server_url, const std::string& consumer_key);
// Cache get_cache(std::string code);
Caches get_caches(const std::vector<std::string>& codes) const;
Caches get_caches(const std::set<std::string>& codes) const;
Caches get_user_caches(const std::string& uuid, int count = 0) const override;
std::string get_changelog_json(int revision) const;