Pull more cache data from local db

sql-rework
Tomasz Goliński 2019-11-04 11:09:47 +01:00
rodzic 10b4562ac0
commit 46a7321434
1 zmienionych plików z 9 dodań i 2 usunięć

Wyświetl plik

@ -315,8 +315,8 @@ Caches OCdb::get_user_caches(std::string uuid, __attribute__((unused)) int count
int res;
Caches cc;
Cache c;
std::string sql = "SELECT code, location FROM caches WHERE EXISTS (SELECT cache_code FROM logs WHERE cache_code = code AND type = 'Found it' and user = ?);";
//code TEXT PRIMARY KEY, name TEXT, location TEXT, type TEXT, status TEXT, size TEXT, difficulty REAL, terrain REAL, country TEXT, region TEXT, owner TEXT)
std::string sql = "SELECT code, location, type, size, difficulty, terrain, country, region, owner FROM caches WHERE EXISTS (SELECT cache_code FROM logs WHERE cache_code = code AND type = 'Found it' and user = ?);";
res = sqlite3_prepare_v2(db, sql.c_str(), sql.length() + 1, &stmt, NULL);
if (res != SQLITE_OK) {
@ -329,6 +329,13 @@ Caches OCdb::get_user_caches(std::string uuid, __attribute__((unused)) int count
while (res == SQLITE_ROW) {
c.code = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 0));
c.pos = get_lat_lon(reinterpret_cast<const char*>(sqlite3_column_text(stmt, 1)));
c.type = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 2));
c.size = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 3));
c.diff = sqlite3_column_double(stmt, 4);
c.terr = sqlite3_column_double(stmt, 5);
// c.country = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 6));
c.region = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 7));
c.owner_uuid = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 8)); // TODO: we don't know owner's nick
cc.insert(c);
res = sqlite3_step(stmt);
}