Utilize VolatileStateResults where applicable

This commit is contained in:
Johannes Meyer 2021-10-06 15:34:36 +02:00
parent 9bd3f99673
commit 7efb797fbb
6 changed files with 19 additions and 0 deletions

View file

@ -15,6 +15,7 @@ use Icinga\Module\Icingadb\Model\History;
use Icinga\Module\Icingadb\Model\Host;
use Icinga\Module\Icingadb\Model\Service;
use Icinga\Module\Icingadb\Model\ServicestateSummary;
use Icinga\Module\Icingadb\Redis\VolatileStateResults;
use Icinga\Module\Icingadb\Web\Controller;
use Icinga\Module\Icingadb\Widget\Detail\HostDetail;
use Icinga\Module\Icingadb\Widget\Detail\HostInspectionDetail;
@ -38,6 +39,7 @@ class HostController extends Controller
$name = $this->params->getRequired('name');
$query = Host::on($this->getDb())->with(['state', 'icon_image']);
$query->setResultSetClass(VolatileStateResults::class);
$query->getSelectBase()
->where(['host.name = ?' => $name]);
@ -188,6 +190,7 @@ class HostController extends Controller
'host',
'host.state'
]);
$services->setResultSetClass(VolatileStateResults::class);
$services
->getSelectBase()

View file

@ -7,6 +7,7 @@ namespace Icinga\Module\Icingadb\Controllers;
use Icinga\Exception\NotFoundError;
use Icinga\Module\Icingadb\Model\Host;
use Icinga\Module\Icingadb\Model\Hostgroupsummary;
use Icinga\Module\Icingadb\Redis\VolatileStateResults;
use Icinga\Module\Icingadb\Web\Controller;
use Icinga\Module\Icingadb\Widget\ItemList\HostList;
use Icinga\Module\Icingadb\Widget\ItemList\HostgroupList;
@ -46,6 +47,7 @@ class HostgroupController extends Controller
$db = $this->getDb();
$hosts = Host::on($db)->with(['state', 'state.last_comment', 'icon_image'])->utilize('hostgroup');
$hosts->setResultSetClass(VolatileStateResults::class);
$hosts->getSelectBase()->where(['host_hostgroup.id = ?' => $this->hostgroup->id]);
$this->applyRestrictions($hosts);

View file

@ -9,6 +9,7 @@ use Icinga\Module\Icingadb\Common\CommandActions;
use Icinga\Module\Icingadb\Common\Links;
use Icinga\Module\Icingadb\Model\Host;
use Icinga\Module\Icingadb\Model\HoststateSummary;
use Icinga\Module\Icingadb\Redis\VolatileStateResults;
use Icinga\Module\Icingadb\Util\FeatureStatus;
use Icinga\Module\Icingadb\Web\Control\SearchBar\ObjectSuggestions;
use Icinga\Module\Icingadb\Web\Controller;
@ -36,6 +37,7 @@ class HostsController extends Controller
$db = $this->getDb();
$hosts = Host::on($db)->with(['state', 'icon_image', 'state.last_comment']);
$hosts->setResultSetClass(VolatileStateResults::class);
$this->handleSearchRequest($hosts);
@ -124,6 +126,7 @@ class HostsController extends Controller
$db = $this->getDb();
$hosts = Host::on($db)->with(['state', 'icon_image']);
$hosts->setResultSetClass(VolatileStateResults::class);
$summary = HoststateSummary::on($db)->with(['state']);
$this->filter($hosts);
@ -194,6 +197,7 @@ class HostsController extends Controller
$db = $this->getDb();
$hosts = Host::on($db)->with('state');
$hosts->setResultSetClass(VolatileStateResults::class);
switch ($this->getRequest()->getActionName()) {
case 'acknowledge':

View file

@ -13,6 +13,7 @@ use Icinga\Module\Icingadb\Common\ServiceLinks;
use Icinga\Module\Icingadb\Hook\TabHook\HookActions;
use Icinga\Module\Icingadb\Model\History;
use Icinga\Module\Icingadb\Model\Service;
use Icinga\Module\Icingadb\Redis\VolatileStateResults;
use Icinga\Module\Icingadb\Web\Controller;
use Icinga\Module\Icingadb\Widget\Detail\QuickActions;
use Icinga\Module\Icingadb\Widget\Detail\ServiceDetail;
@ -41,6 +42,8 @@ class ServiceController extends Controller
'host',
'host.state'
]);
$query->setResultSetClass(VolatileStateResults::class);
$query->getSelectBase()
->where(['service.name = ?' => $name])
->where(['service_host.name = ?' => $hostName]);

View file

@ -7,6 +7,7 @@ namespace Icinga\Module\Icingadb\Controllers;
use Icinga\Exception\NotFoundError;
use Icinga\Module\Icingadb\Model\Service;
use Icinga\Module\Icingadb\Model\ServicegroupSummary;
use Icinga\Module\Icingadb\Redis\VolatileStateResults;
use Icinga\Module\Icingadb\Web\Controller;
use Icinga\Module\Icingadb\Widget\ItemList\ServiceList;
use Icinga\Module\Icingadb\Widget\ItemList\ServicegroupList;
@ -52,6 +53,7 @@ class ServicegroupController extends Controller
'host',
'host.state'
])->utilize('servicegroup');
$services->setResultSetClass(VolatileStateResults::class);
$services->getSelectBase()->where(['service_servicegroup.id = ?' => $this->servicegroup->id]);
$this->applyRestrictions($services);

View file

@ -10,6 +10,7 @@ use Icinga\Module\Icingadb\Common\Links;
use Icinga\Module\Icingadb\Data\PivotTable;
use Icinga\Module\Icingadb\Model\Service;
use Icinga\Module\Icingadb\Model\ServicestateSummary;
use Icinga\Module\Icingadb\Redis\VolatileStateResults;
use Icinga\Module\Icingadb\Util\FeatureStatus;
use Icinga\Module\Icingadb\Web\Control\ProblemToggle;
use Icinga\Module\Icingadb\Web\Control\SearchBar\ObjectSuggestions;
@ -45,6 +46,7 @@ class ServicesController extends Controller
'host.state',
'icon_image'
]);
$services->setResultSetClass(VolatileStateResults::class);
$this->handleSearchRequest($services);
@ -139,6 +141,7 @@ class ServicesController extends Controller
'host',
'host.state'
]);
$services->setResultSetClass(VolatileStateResults::class);
$summary = ServicestateSummary::on($db)->with(['state']);
$this->filter($services);
@ -214,6 +217,7 @@ class ServicesController extends Controller
'host',
'host.state'
]);
$query->setResultSetClass(VolatileStateResults::class);
$this->handleSearchRequest($query);
@ -317,6 +321,7 @@ class ServicesController extends Controller
'host',
'host.state'
]);
$services->setResultSetClass(VolatileStateResults::class);
switch ($this->getRequest()->getActionName()) {
case 'acknowledge':