aboutsummaryrefslogtreecommitdiff
path: root/mod/database-module.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2024-12-02 11:45:35 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2024-12-10 16:44:55 +0200
commit3871a466fa21ed7ecb6a7b1d1d5ef4d14b736a48 (patch)
treeca7ef104f5c47c86127afd8f592a512385b8601c /mod/database-module.cxx
parent1d0a198748c0e4aa1ce22ab2989a2b734f7d8948 (diff)
Add tenant id to tenant service notifications and callbacks
Diffstat (limited to 'mod/database-module.cxx')
-rw-r--r--mod/database-module.cxx20
1 files changed, 15 insertions, 5 deletions
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<string> database_module::
update_tenant_service_state (
const connection_ptr& conn,
- const string& tid,
- const function<optional<string> (const tenant_service&)>& f)
+ const string& type,
+ const string& id,
+ const function<optional<string> (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<build_tenant> t (build_db_->find<build_tenant> (tid));
+ using query = query<build_tenant>;
- if (t != nullptr && t->service)
+ shared_ptr<build_tenant> t (
+ build_db_->query_one<build_tenant> (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<string> data = f (s))
+ if (optional<string> data = f (t->id, s))
{
s.data = move (*data);
build_db_->update (t);