From 3871a466fa21ed7ecb6a7b1d1d5ef4d14b736a48 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 2 Dec 2024 11:45:35 +0200 Subject: Add tenant id to tenant service notifications and callbacks --- mod/database-module.cxx | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'mod/database-module.cxx') diff --git a/mod/database-module.cxx b/mod/database-module.cxx index bce8c93..629e393 100644 --- a/mod/database-module.cxx +++ b/mod/database-module.cxx @@ -79,8 +79,10 @@ namespace brep optional database_module:: update_tenant_service_state ( const connection_ptr& conn, - const string& tid, - const function (const tenant_service&)>& f) + const string& type, + const string& id, + const function (const string& tenant_id, + const tenant_service&)>& f) { assert (f != nullptr); // Shouldn't be called otherwise. @@ -96,13 +98,21 @@ namespace brep { transaction tr (conn->begin ()); - shared_ptr t (build_db_->find (tid)); + using query = query; - if (t != nullptr && t->service) + shared_ptr t ( + build_db_->query_one (query::service.id == id && + query::service.type == type)); + + if (t != nullptr) { + // Shouldn't be here otherwise. + // + assert (t->service); + tenant_service& s (*t->service); - if (optional data = f (s)) + if (optional data = f (t->id, s)) { s.data = move (*data); build_db_->update (t); -- cgit v1.1