OCdb exclude owned caches in not found list, extract also cache name

sql-rework
Tomasz Golinski 2020-03-29 19:52:49 +02:00
rodzic 8e15d95be6
commit e00ce62e72
1 zmienionych plików z 2 dodań i 1 usunięć

Wyświetl plik

@ -316,7 +316,7 @@ Caches OCdb::get_user_caches_not_found(const std::string& uuid) const {
Caches cc;
Cache c;
std::string sql = "SELECT code, location FROM caches WHERE status = 'Available' AND NOT EXISTS (SELECT cache_code FROM logs WHERE cache_code = code AND type = 1 and user = ?);";
std::string sql = "SELECT code, location, name FROM caches WHERE status = 'Available' AND NOT EXISTS (SELECT cache_code FROM logs WHERE cache_code = code AND type = 1 and user = ?1) AND owner != ?1;";
res = sqlite3_prepare_v2(db, sql.c_str(), sql.length() + 1, &stmt, NULL);
if (res != SQLITE_OK) {
@ -330,6 +330,7 @@ Caches OCdb::get_user_caches_not_found(const std::string& uuid) const {
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.name = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 2));
c.status = ok;
cc.push_back(c);
res = sqlite3_step(stmt);