kopia lustrzana https://gitlab.com/tomaszg/geostat
Possibility to apply changelogs grabbed from OKapi
rodzic
27d29af9ed
commit
dc91a5c1ed
10
ocdb.cpp
10
ocdb.cpp
|
@ -82,6 +82,16 @@ bool OCdb::init_part(std::string json_file) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OCdb::update(Okapi& oc) {
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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_cache = "services/caches/geocache";
|
||||||
static const std::string OKAPI_caches = "services/caches/geocaches";
|
static const std::string OKAPI_caches = "services/caches/geocaches";
|
||||||
static const std::string OKAPI_username = "services/users/by_username";
|
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
|
// 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) {
|
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));
|
json j = json::parse(curl_post(service, query));
|
||||||
return j["uuid"];
|
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);
|
||||||
|
}
|
||||||
|
|
1
okapi.h
1
okapi.h
|
@ -21,6 +21,7 @@ public:
|
||||||
// Cache get_cache(std::string code);
|
// Cache get_cache(std::string code);
|
||||||
Caches get_caches(std::vector<std::string> codes);
|
Caches get_caches(std::vector<std::string> codes);
|
||||||
Caches get_user_caches(std::string uuid, int count = 0);
|
Caches get_user_caches(std::string uuid, int count = 0);
|
||||||
|
std::string get_changelog_json(int revision);
|
||||||
|
|
||||||
std::string get_uuid(std::string username);
|
std::string get_uuid(std::string username);
|
||||||
};
|
};
|
||||||
|
|
Ładowanie…
Reference in New Issue