From 39a7404e6cddb2053a87f86935cda566c54bd4e6 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 22 Mar 2024 18:00:37 +0300 Subject: Add tenant_service_hints --- mod/mod-build-result.cxx | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'mod/mod-build-result.cxx') diff --git a/mod/mod-build-result.cxx b/mod/mod-build-result.cxx index 605f83d..ccce17f 100644 --- a/mod/mod-build-result.cxx +++ b/mod/mod-build-result.cxx @@ -199,12 +199,13 @@ handle (request& rq, response&) // // If the package build is interrupted and the tenant_service_build_queued // callback is associated with the package tenant, then stash the state, the - // build object, and the callback pointer for the subsequent service - // `queued` notification. + // build object, and the callback pointer and calculate the hints for the + // subsequent service `queued` notification. // const tenant_service_build_built* tsb (nullptr); const tenant_service_build_queued* tsq (nullptr); optional>> tss; + tenant_service_build_queued::build_queued_hints qhs; // Note that if the session authentication fails (probably due to the // authentication settings change), then we log this case with the warning @@ -342,6 +343,20 @@ handle (request& rq, response&) // if (tsq != nullptr) { + // Calculate the tenant service hints. + // + buildable_package_count tpc ( + build_db_->query_value ( + query::build_tenant::id == t->id)); + + shared_ptr p ( + build_db_->load (b->id.package)); + + qhs = tenant_service_build_queued::build_queued_hints { + tpc == 1, p->configs.size () == 1}; + + // Set the package tenant's queued timestamp. + // t->queued_timestamp = system_clock::now (); build_db_->update (t); } @@ -503,7 +518,11 @@ handle (request& rq, response&) vector qbs; qbs.push_back (move (*tss->second)); - if (auto f = tsq->build_queued (ss, qbs, build_state::building, log_writer_)) + if (auto f = tsq->build_queued (ss, + qbs, + build_state::building, + qhs, + log_writer_)) update_tenant_service_state (conn, qbs.back ().tenant, f); } -- cgit v1.1