From 2b31e5cb109e2b009529e97f4fdb4a707cae14f2 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 13 Jun 2017 17:52:42 +0300 Subject: Add builds to package version details page --- mod/mod-package-version-details.cxx | 57 +++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'mod/mod-package-version-details.cxx') diff --git a/mod/mod-package-version-details.cxx b/mod/mod-package-version-details.cxx index a359104..7dc02d2 100644 --- a/mod/mod-package-version-details.cxx +++ b/mod/mod-package-version-details.cxx @@ -14,6 +14,8 @@ #include #include +#include +#include #include #include @@ -45,6 +47,11 @@ init (scanner& s) database_module::init (*options_, options_->package_db_retry ()); + if (options_->build_config_specified ()) + database_module::init (static_cast (*options_), + static_cast (*options_), + options_->build_db_retry ()); + if (options_->root ().empty ()) options_->root (dir_path ("/")); } @@ -58,6 +65,7 @@ handle (request& rq, response& rs) MODULE_DIAG; + const string& host (options_->host ()); const dir_path& root (options_->root ()); auto i (rq.path ().rbegin ()); @@ -317,6 +325,55 @@ handle (request& rq, response& rs) << ~TABLE; } + // Don't display the section for stub packages. + // + if (build_db_ != nullptr && ver.compare (wildcard_version, true) != 0) + { + s << H3 << "Built" << ~H3 + << DIV(ID="built"); + + timestamp now (timestamp::clock::now ()); + transaction t (build_db_->begin ()); + + using query = query; + + for (auto& b: build_db_->query ( + (query::id.package.name == name && + compare_version_eq (query::id.package.version, ver, true) && + + query::id.configuration.in_range (build_conf_names_->begin (), + build_conf_names_->end ())) + + + "ORDER BY" + query::timestamp + "DESC")) + { + string ts (butl::to_string (b.timestamp, + "%Y-%m-%d %H:%M:%S %Z", + true, + true) + + " (" + butl::to_string (now - b.timestamp, false) + " ago)"); + + if (b.state == build_state::built) + build_db_->load (b, b.results_section); + + s << TABLE(CLASS="proplist build") + << TBODY + << TR_VALUE ("toolchain", + b.toolchain_name + '-' + + b.toolchain_version.string ()) + << TR_VALUE ("config", + b.configuration + " / " + b.machine + " / " + + (b.target ? b.target->string () : "")) + << TR_VALUE ("timestamp", ts) + << TR_BUILD_RESULT (b, host, root) + << ~TBODY + << ~TABLE; + } + + t.commit (); + + s << ~DIV; + } + const auto& ch (pkg->changes); if (!ch.empty ()) s << H3 << "Changes" << ~H3 -- cgit v1.1