fix: load less from database on mqtt publish

This commit is contained in:
Tobias Reisinger 2020-08-28 23:26:22 +02:00
parent 6117548e32
commit 6728ef9264
6 changed files with 40 additions and 25 deletions
src/models

View file

@ -324,6 +324,20 @@ controller_get_by_uid(uuid_t uid)
return result;
}
int
controller_get_id_for_uid(uuid_t uid)
{
char uuid_str[UUID_STR_LEN];
uuid_unparse(uid, uuid_str);
LOGGER_DEBUG("getting controller id [uid=%s] from database\n", uuid_str);
sqlite3_stmt *stmt;
sqlite3_prepare_v2(global_database, "SELECT id FROM controllers WHERE uid = ?1;", -1, &stmt, NULL);
sqlite3_bind_blob(stmt, 1, uid, sizeof(uuid_t), SQLITE_STATIC);
return database_helper_get_id(stmt);
}
controller_t**
controller_get_all()
{