summaryrefslogtreecommitdiffstats
path: root/library/Director/Objects/SyncRun.php
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:43:12 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:43:12 +0000
commitcd989f9c3aff968e19a3aeabc4eb9085787a6673 (patch)
treefbff2135e7013f196b891bbde54618eb050e4aaf /library/Director/Objects/SyncRun.php
parentInitial commit. (diff)
downloadicingaweb2-module-director-upstream.tar.xz
icingaweb2-module-director-upstream.zip
Adding upstream version 1.10.2.upstream/1.10.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/Director/Objects/SyncRun.php')
-rw-r--r--library/Director/Objects/SyncRun.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/library/Director/Objects/SyncRun.php b/library/Director/Objects/SyncRun.php
new file mode 100644
index 0000000..62f7378
--- /dev/null
+++ b/library/Director/Objects/SyncRun.php
@@ -0,0 +1,46 @@
+<?php
+
+namespace Icinga\Module\Director\Objects;
+
+use Icinga\Module\Director\Data\Db\DbObject;
+
+class SyncRun extends DbObject
+{
+ protected $table = 'sync_run';
+
+ protected $keyName = 'id';
+
+ protected $autoincKeyName = 'id';
+
+ protected $defaultProperties = array(
+ 'id' => null,
+ 'rule_id' => null,
+ 'rule_name' => null,
+ 'start_time' => null,
+ 'duration_ms' => null,
+ 'objects_created' => null,
+ 'objects_deleted' => null,
+ 'objects_modified' => null,
+ 'last_former_activity' => null,
+ 'last_related_activity' => null,
+ );
+
+ public static function start(SyncRule $rule)
+ {
+ return static::create(
+ array(
+ 'start_time' => date('Y-m-d H:i:s'),
+ 'rule_id' => $rule->id,
+ 'rule_name' => $rule->rule_name,
+ ),
+ $rule->getConnection()
+ );
+ }
+
+ public function countActivities()
+ {
+ return (int) $this->get('objects_deleted')
+ + (int) $this->get('objects_created')
+ + (int) $this->get('objects_modified');
+ }
+}