aboutsummaryrefslogtreecommitdiff
path: root/libbrep
diff options
context:
space:
mode:
Diffstat (limited to 'libbrep')
-rw-r--r--libbrep/build-extra.sql2
-rw-r--r--libbrep/build-package.hxx15
-rw-r--r--libbrep/build.hxx2
-rw-r--r--libbrep/build.xml2
-rw-r--r--libbrep/package.hxx28
-rw-r--r--libbrep/package.xml9
6 files changed, 53 insertions, 5 deletions
diff --git a/libbrep/build-extra.sql b/libbrep/build-extra.sql
index 9e51a51..c31cc31 100644
--- a/libbrep/build-extra.sql
+++ b/libbrep/build-extra.sql
@@ -46,10 +46,12 @@ CREATE FOREIGN TABLE build_tenant (
id TEXT NOT NULL,
private BOOLEAN NOT NULL,
interactive TEXT NULL,
+ creation_timestamp BIGINT NOT NULL,
archived BOOLEAN NOT NULL,
service_id TEXT NULL,
service_type TEXT NULL,
service_data TEXT NULL,
+ loaded_timestamp BIGINT NULL,
queued_timestamp BIGINT NULL,
toolchain_name TEXT OPTIONS (column_name 'build_toolchain_name') NULL,
toolchain_version_epoch INTEGER OPTIONS (column_name 'build_toolchain_version_epoch') NULL,
diff --git a/libbrep/build-package.hxx b/libbrep/build-package.hxx
index 9a9c277..2611678 100644
--- a/libbrep/build-package.hxx
+++ b/libbrep/build-package.hxx
@@ -32,12 +32,23 @@ namespace brep
class build_tenant
{
public:
+ // Create tenant for an unloaded CI request (see the build_unloaded()
+ // tenant services notification for details).
+ //
+ build_tenant (string i, tenant_service s, timestamp l)
+ : id (move (i)),
+ creation_timestamp (timestamp::clock::now ()),
+ service (move (s)),
+ loaded_timestamp (l) {}
+
string id;
- bool private_;
+ bool private_ = false;
optional<string> interactive;
- bool archived;
+ timestamp creation_timestamp;
+ bool archived = false;
optional<tenant_service> service;
+ optional<timestamp> loaded_timestamp;
optional<timestamp> queued_timestamp;
optional<build_toolchain> toolchain;
diff --git a/libbrep/build.hxx b/libbrep/build.hxx
index af49c03..55fd42b 100644
--- a/libbrep/build.hxx
+++ b/libbrep/build.hxx
@@ -28,7 +28,7 @@
//
#define LIBBREP_BUILD_SCHEMA_VERSION_BASE 20
-#pragma db model version(LIBBREP_BUILD_SCHEMA_VERSION_BASE, 27, closed)
+#pragma db model version(LIBBREP_BUILD_SCHEMA_VERSION_BASE, 28, closed)
// We have to keep these mappings at the global scope instead of inside the
// brep namespace because they need to be also effective in the bbot namespace
diff --git a/libbrep/build.xml b/libbrep/build.xml
index 1eba85a..90b4b4f 100644
--- a/libbrep/build.xml
+++ b/libbrep/build.xml
@@ -1,4 +1,6 @@
<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" database="pgsql" schema-name="build" version="1">
+ <changeset version="28"/>
+
<changeset version="27"/>
<changeset version="26"/>
diff --git a/libbrep/package.hxx b/libbrep/package.hxx
index 45008d4..affa2ac 100644
--- a/libbrep/package.hxx
+++ b/libbrep/package.hxx
@@ -20,7 +20,7 @@
//
#define LIBBREP_PACKAGE_SCHEMA_VERSION_BASE 27
-#pragma db model version(LIBBREP_PACKAGE_SCHEMA_VERSION_BASE, 33, closed)
+#pragma db model version(LIBBREP_PACKAGE_SCHEMA_VERSION_BASE, 34, closed)
namespace brep
{
@@ -260,11 +260,17 @@ namespace brep
//
optional<string> interactive; // Note: foreign-mapped in build.
- timestamp creation_timestamp;
+ timestamp creation_timestamp; // Note: foreign-mapped in build.
bool archived = false; // Note: foreign-mapped in build.
optional<tenant_service> service; // Note: foreign-mapped in build.
+ // If the tenant is loaded, this value is absent. Otherwise it is the time
+ // of the last attempt to load the tenant (see the build_unloaded() tenant
+ // services notification for details).
+ //
+ optional<timestamp> loaded_timestamp; // Note: foreign-mapped in build.
+
// Note that due to the implementation complexity and performance
// considerations, the service notifications are not synchronized. This
// leads to a potential race, so that before we have sent the `queued`
@@ -318,6 +324,10 @@ namespace brep
#pragma db index member(service.id)
+ // Speed-up queries with ordering the result by loaded_timestamp.
+ //
+ #pragma db member(loaded_timestamp) index
+
private:
friend class odb::access;
tenant () = default;
@@ -427,6 +437,20 @@ namespace brep
repository (): tenant (id.tenant), canonical_name (id.canonical_name) {}
};
+ // Repositories count.
+ //
+ #pragma db view object(repository)
+ struct repository_count
+ {
+ size_t result;
+
+ operator size_t () const {return result;}
+
+ // Database mapping.
+ //
+ #pragma db member(result) column("count(" + repository::id.tenant + ")")
+ };
+
// The 'to' expression calls the PostgreSQL to_tsvector(weighted_text)
// function overload (package-extra.sql). Since we are only interested
// in "write-only" members of this type, make the 'from' expression
diff --git a/libbrep/package.xml b/libbrep/package.xml
index 96e93a7..fe010ad 100644
--- a/libbrep/package.xml
+++ b/libbrep/package.xml
@@ -1,4 +1,13 @@
<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" database="pgsql" schema-name="package" version="1">
+ <changeset version="34">
+ <alter-table name="tenant">
+ <add-column name="loaded_timestamp" type="BIGINT" null="true"/>
+ <add-index name="tenant_loaded_timestamp_i">
+ <column name="loaded_timestamp"/>
+ </add-index>
+ </alter-table>
+ </changeset>
+
<changeset version="33">
<add-table name="public_key" kind="object">
<column name="tenant" type="TEXT" null="false"/>