kopia lustrzana https://gitlab.com/tomaszg/geostat
Encapsulate revision in OCdb
rodzic
f7e02612d8
commit
9d9601e4ca
16
ocdb.cpp
16
ocdb.cpp
|
|
@ -62,7 +62,7 @@ bool OCdb::init(std::string dump_path) {
|
||||||
for (auto& el : j["data_files"].items()) {
|
for (auto& el : j["data_files"].items()) {
|
||||||
init_part(dump_path + el.value().get<std::string>());
|
init_part(dump_path + el.value().get<std::string>());
|
||||||
}
|
}
|
||||||
request("UPDATE revision SET revision = " + std::to_string(revision) + ';');
|
request("COMMIT;");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -89,9 +89,8 @@ bool OCdb::update(Okapi& oc) {
|
||||||
for (auto& el : j["changelog"].items()) {
|
for (auto& el : j["changelog"].items()) {
|
||||||
parse_item(el.value());
|
parse_item(el.value());
|
||||||
}
|
}
|
||||||
revision = j["revision"];
|
set_revision(j["revision"]);
|
||||||
request("UPDATE revision SET revision = " + std::to_string(revision) + ';');
|
request("COMMIT;");
|
||||||
request("COMMIT");
|
|
||||||
if (j["more"])
|
if (j["more"])
|
||||||
update(oc);
|
update(oc);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -341,3 +340,12 @@ Caches OCdb::get_user_caches(std::string uuid, int count) {
|
||||||
// sqlite3_finalize(stmt);
|
// sqlite3_finalize(stmt);
|
||||||
return cc;
|
return cc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int OCdb::get_revision() {
|
||||||
|
return revision;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OCdb::set_revision(int rev) {
|
||||||
|
revision = rev;
|
||||||
|
request("UPDATE revision SET revision = " + std::to_string(revision) + ';');
|
||||||
|
}
|
||||||
|
|
|
||||||
5
ocdb.h
5
ocdb.h
|
|
@ -16,6 +16,7 @@ class OCdb : public Api {
|
||||||
private:
|
private:
|
||||||
sqlite3* db;
|
sqlite3* db;
|
||||||
sqlite3_stmt* stmt;
|
sqlite3_stmt* stmt;
|
||||||
|
int revision;
|
||||||
|
|
||||||
bool request(std::string req);
|
bool request(std::string req);
|
||||||
bool init_part(std::string json_file); // read db dump
|
bool init_part(std::string json_file); // read db dump
|
||||||
|
|
@ -24,13 +25,13 @@ private:
|
||||||
bool update_log(json j);
|
bool update_log(json j);
|
||||||
bool read_revision();
|
bool read_revision();
|
||||||
public:
|
public:
|
||||||
int revision;
|
|
||||||
|
|
||||||
OCdb(std::string db_file);
|
OCdb(std::string db_file);
|
||||||
~OCdb();
|
~OCdb();
|
||||||
|
|
||||||
bool init(std::string json_file); // read db dump
|
bool init(std::string json_file); // read db dump
|
||||||
bool update(Okapi& oc); // apply changelog
|
bool update(Okapi& oc); // apply changelog
|
||||||
|
int get_revision();
|
||||||
|
void set_revision(int rev);
|
||||||
|
|
||||||
Caches get_user_caches_not_found(std::string uuid);
|
Caches get_user_caches_not_found(std::string uuid);
|
||||||
Caches get_user_caches(std::string uuid, int count = 0);
|
Caches get_user_caches(std::string uuid, int count = 0);
|
||||||
|
|
|
||||||
Ładowanie…
Reference in New Issue