Possibility to apply changelogs grabbed from OKapi

sql-rework
Tomasz Golinski 2019-10-01 01:49:25 +02:00
rodzic 27d29af9ed
commit dc91a5c1ed
3 zmienionych plików z 18 dodań i 0 usunięć

Wyświetl plik

@ -82,6 +82,16 @@ bool OCdb::init_part(std::string json_file) {
}
bool OCdb::update(Okapi& oc) {
Debug(2) << "Fetching changelog since revision " << revision << ".\n";
std::string output = oc.get_changelog_json(revision);
json j = json::parse(output);
for (auto& el : j["changelog"].items()) {
parse_item(el.value());
}
revision = j["revision"];
if (j["more"])
update(oc);
return 1;
}

Wyświetl plik

@ -14,6 +14,7 @@ static const std::string OKAPI_logs = "services/logs/userlogs";
static const std::string OKAPI_cache = "services/caches/geocache";
static const std::string OKAPI_caches = "services/caches/geocaches";
static const std::string OKAPI_username = "services/users/by_username";
static const std::string OKAPI_changelog = "services/replicate/changelog";
// Callback for cURL easy interface used to save received output to std::string object
size_t Okapi::write_cb(char* ptr, size_t size, size_t nmemb, void* userdata) {
@ -184,3 +185,9 @@ std::string Okapi::get_uuid(std::string username) {
json j = json::parse(curl_post(service, query));
return j["uuid"];
}
std::string Okapi::get_changelog_json(int revision) {
std::string service = url + OKAPI_changelog;
std::string query = "consumer_key=" + key + "&since=" + std::to_string(revision);
return curl_post(service, query);
}

Wyświetl plik

@ -21,6 +21,7 @@ public:
// Cache get_cache(std::string code);
Caches get_caches(std::vector<std::string> codes);
Caches get_user_caches(std::string uuid, int count = 0);
std::string get_changelog_json(int revision);
std::string get_uuid(std::string username);
};