From 10ab5a9bdc0e27691ec2d09772c8e62587b779a7 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 15 Feb 2024 13:37:31 +0300 Subject: Cleanup build queries in monitor --- libbrep/build.hxx | 35 +++++++++++++++++++++++++++++++++++ libbrep/common.hxx | 37 ++++++++++++++++++++++++++----------- 2 files changed, 61 insertions(+), 11 deletions(-) (limited to 'libbrep') diff --git a/libbrep/build.hxx b/libbrep/build.hxx index 236f73c..1e9a9fc 100644 --- a/libbrep/build.hxx +++ b/libbrep/build.hxx @@ -127,6 +127,41 @@ namespace brep compare_version_ne (x.toolchain_version, y.toolchain_version, true); } + // Allow comparing the query members with the query parameters bound by + // reference to variables of the build id type (in particular in the + // prepared queries). + // + // Note that it is not operator==() since the query template parameter type + // can not be deduced from the function parameter types and needs to be + // specified explicitly. + // + template + inline auto + equal (const ID& x, const build_id& y, bool toolchain_version = true) + -> decltype (x.package.tenant == odb::query::_ref (y.package.tenant) && + x.package.name == odb::query::_ref (y.package.name) && + x.package.version.epoch == + odb::query::_ref (y.package.version.epoch) && + x.target_config_name == + odb::query::_ref (y.target_config_name) && + x.toolchain_name == odb::query::_ref (y.toolchain_name) && + x.toolchain_version.epoch == + odb::query::_ref (y.toolchain_version.epoch)) + { + using query = odb::query; + + query r (equal (x.package, y.package) && + x.target == query::_ref (y.target) && + x.target_config_name == query::_ref (y.target_config_name) && + x.package_config_name == query::_ref (y.package_config_name) && + x.toolchain_name == query::_ref (y.toolchain_name)); + + if (toolchain_version) + r = r && equal (x.toolchain_version, y.toolchain_version); + + return r; + } + // build_state // // The queued build state is semantically equivalent to a non-existent diff --git a/libbrep/common.hxx b/libbrep/common.hxx index 11aae67..04d8453 100644 --- a/libbrep/common.hxx +++ b/libbrep/common.hxx @@ -737,6 +737,27 @@ namespace brep } // Allow comparing the query members with the query parameters bound by + // reference to variables of the canonical version type (in particular in + // the prepared queries). + // + // Note that it is not operator==() since the query template parameter type + // can not be deduced from the function parameter types and needs to be + // specified explicitly. + // + template + inline auto + equal (const V& x, const canonical_version& y) + -> decltype (x.epoch == odb::query::_ref (y.epoch)) + { + using query = odb::query; + + return x.epoch == query::_ref (y.epoch) && + x.canonical_upstream == query::_ref (y.canonical_upstream) && + x.canonical_release == query::_ref (y.canonical_release) && + x.revision == query::_ref (y.revision); + } + + // Allow comparing the query members with the query parameters bound by // reference to variables of the package id type (in particular in the // prepared queries). // @@ -747,21 +768,15 @@ namespace brep template inline auto equal (const ID& x, const package_id& y) - -> decltype (x.tenant == odb::query::_ref (y.tenant) && - x.name == odb::query::_ref (y.name) && + -> decltype (x.tenant == odb::query::_ref (y.tenant) && + x.name == odb::query::_ref (y.name) && x.version.epoch == odb::query::_ref (y.version.epoch)) { using query = odb::query; - const auto& qv (x.version); - const canonical_version& v (y.version); - - return x.tenant == query::_ref (y.tenant) && - x.name == query::_ref (y.name) && - qv.epoch == query::_ref (v.epoch) && - qv.canonical_upstream == query::_ref (v.canonical_upstream) && - qv.canonical_release == query::_ref (v.canonical_release) && - qv.revision == query::_ref (v.revision); + return x.tenant == query::_ref (y.tenant) && + x.name == query::_ref (y.name) && + equal (x.version, y.version); } // Repository id comparison operators. -- cgit v1.1