aboutsummaryrefslogtreecommitdiff
path: root/libbrep/package.hxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2024-05-21 13:48:43 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2024-05-21 13:50:10 +0300
commitbad54b28bcc59fe5d19ecaf486f52e6359009e68 (patch)
tree4dcc9c10413d46bf9f506863b6f154ee5998e469 /libbrep/package.hxx
parentc4798955364d3a5e4074e56a0038148837c75d82 (diff)
Add support for build_unloaded() notification for tenant-associated services
Diffstat (limited to 'libbrep/package.hxx')
-rw-r--r--libbrep/package.hxx28
1 files changed, 26 insertions, 2 deletions
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