[icinga-checkins] icinga.org: icingaweb2-module-director/master: Db: allow to fetch object-based undeployed changes

git at icinga.org git at icinga.org
Sat Feb 27 12:23:17 CET 2016


Module: icingaweb2-module-director
Branch: master
Commit: 3503fce64f29659763274582394c4fc149ced02f
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=3503fce64f29659763274582394c4fc149ced02f

Author: Thomas Gelf <thomas at gelf.net>
Date:   Sat Feb 27 12:07:50 2016 +0100

Db: allow to fetch object-based undeployed changes

---

 library/Director/Db.php |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/library/Director/Db.php b/library/Director/Db.php
index 3e6745d..44e588a 100644
--- a/library/Director/Db.php
+++ b/library/Director/Db.php
@@ -5,6 +5,7 @@ namespace Icinga\Module\Director;
 use Icinga\Data\Db\DbConnection;
 use Icinga\Module\Director\Objects\DirectorDeploymentLog;
 use Icinga\Module\Director\Objects\IcingaEndpoint;
+use Icinga\Module\Director\Objects\IcingaObject;
 use Icinga\Exception\ConfigurationError;
 use Zend_Db_Expr;
 use Zend_Db_Select;
@@ -24,8 +25,10 @@ class Db extends DbConnection
         return $this->getDbAdapter();
     }
 
-    public function countActivitiesSinceLastDeployedConfig()
+    public function countActivitiesSinceLastDeployedConfig(IcingaObject $object = null)
     {
+        $db = $this->db();
+
         $query = 'SELECT COUNT(*) FROM director_activity_log WHERE id > ('
             . ' SELECT id FROM director_activity_log WHERE checksum = ('
             . '  SELECT last_activity_checksum FROM director_generated_config WHERE checksum = ('
@@ -34,7 +37,11 @@ class Db extends DbConnection
             . ' )'
             . ')';
 
-        return (int) $this->db()->fetchOne($query);
+        if ($object !== null) {
+            $query .= $db->quoteInto(' AND object_type = ?', $object->getTableName());
+            $query .= $db->quoteInto(' AND object_name = ?', $object->object_name);
+        }
+        return (int) $db->fetchOne($query);
     }
 
     public function getMasterZoneName()



More information about the icinga-checkins mailing list