mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-05-28 04:36:06 -04:00
Adjust usages of ipl\Orm\Query::with()
This commit is contained in:
parent
fbc4e80742
commit
a0500c3b67
17 changed files with 192 additions and 206 deletions
|
|
@ -27,14 +27,14 @@ class CommentController extends Controller
|
|||
|
||||
$name = $this->params->getRequired('name');
|
||||
|
||||
$query = Comment::on($this->getDb())->with([
|
||||
'host',
|
||||
'host.state',
|
||||
'service',
|
||||
'service.state',
|
||||
'service.host',
|
||||
'service.host.state'
|
||||
]);
|
||||
$query = Comment::on($this->getDb())
|
||||
->with('host')
|
||||
->with('host.state')
|
||||
->with('service')
|
||||
->with('service.state')
|
||||
->with('service.host')
|
||||
->with('service.host.state');
|
||||
|
||||
$query->filter(Filter::equal('comment.name', $name));
|
||||
|
||||
$this->applyRestrictions($query);
|
||||
|
|
|
|||
|
|
@ -27,14 +27,13 @@ class CommentsController extends Controller
|
|||
|
||||
$db = $this->getDb();
|
||||
|
||||
$comments = Comment::on($db)->with([
|
||||
'host',
|
||||
'host.state',
|
||||
'service',
|
||||
'service.host',
|
||||
'service.host.state',
|
||||
'service.state'
|
||||
]);
|
||||
$comments = Comment::on($db)
|
||||
->with('host')
|
||||
->with('host.state')
|
||||
->with('service')
|
||||
->with('service.host')
|
||||
->with('service.host.state')
|
||||
->with('service.state');
|
||||
|
||||
$this->handleSearchRequest($comments);
|
||||
|
||||
|
|
@ -110,14 +109,13 @@ class CommentsController extends Controller
|
|||
|
||||
$db = $this->getDb();
|
||||
|
||||
$comments = Comment::on($db)->with([
|
||||
'host',
|
||||
'host.state',
|
||||
'service',
|
||||
'service.host',
|
||||
'service.host.state',
|
||||
'service.state'
|
||||
]);
|
||||
$comments = Comment::on($db)
|
||||
->with('host')
|
||||
->with('host.state')
|
||||
->with('service')
|
||||
->with('service.host')
|
||||
->with('service.host.state')
|
||||
->with('service.state');
|
||||
|
||||
$this->filter($comments);
|
||||
|
||||
|
|
@ -142,14 +140,13 @@ class CommentsController extends Controller
|
|||
|
||||
$db = $this->getDb();
|
||||
|
||||
$comments = Comment::on($db)->with([
|
||||
'host',
|
||||
'host.state',
|
||||
'service',
|
||||
'service.host',
|
||||
'service.host.state',
|
||||
'service.state'
|
||||
]);
|
||||
$comments = Comment::on($db)
|
||||
->with('host')
|
||||
->with('host.state')
|
||||
->with('service')
|
||||
->with('service.host')
|
||||
->with('service.host.state')
|
||||
->with('service.state');
|
||||
|
||||
$comments->limit(3)->peekAhead();
|
||||
|
||||
|
|
|
|||
|
|
@ -27,24 +27,23 @@ class DowntimeController extends Controller
|
|||
|
||||
$name = $this->params->getRequired('name');
|
||||
|
||||
$query = Downtime::on($this->getDb())->with([
|
||||
'host',
|
||||
'host.state',
|
||||
'service',
|
||||
'service.state',
|
||||
'service.host',
|
||||
'service.host.state',
|
||||
'parent',
|
||||
'parent.host',
|
||||
'parent.host.state',
|
||||
'parent.service',
|
||||
'parent.service.state',
|
||||
'triggered_by',
|
||||
'triggered_by.host',
|
||||
'triggered_by.host.state',
|
||||
'triggered_by.service',
|
||||
'triggered_by.service.state'
|
||||
]);
|
||||
$query = Downtime::on($this->getDb())
|
||||
->with('host')
|
||||
->with('host.state')
|
||||
->with('service')
|
||||
->with('service.state')
|
||||
->with('service.host')
|
||||
->with('service.host.state')
|
||||
->with('parent')
|
||||
->with('parent.host')
|
||||
->with('parent.host.state')
|
||||
->with('parent.service')
|
||||
->with('parent.service.state')
|
||||
->with('triggered_by')
|
||||
->with('triggered_by.host')
|
||||
->with('triggered_by.host.state')
|
||||
->with('triggered_by.service')
|
||||
->with('triggered_by.service.state');
|
||||
$query->filter(Filter::equal('downtime.name', $name));
|
||||
|
||||
$this->applyRestrictions($query);
|
||||
|
|
|
|||
|
|
@ -27,14 +27,13 @@ class DowntimesController extends Controller
|
|||
|
||||
$db = $this->getDb();
|
||||
|
||||
$downtimes = Downtime::on($db)->with([
|
||||
'host',
|
||||
'host.state',
|
||||
'service',
|
||||
'service.host',
|
||||
'service.host.state',
|
||||
'service.state'
|
||||
]);
|
||||
$downtimes = Downtime::on($db)
|
||||
->with('host')
|
||||
->with('host.state')
|
||||
->with('service')
|
||||
->with('service.host')
|
||||
->with('service.host.state')
|
||||
->with('service.state');
|
||||
|
||||
$this->handleSearchRequest($downtimes);
|
||||
|
||||
|
|
@ -116,14 +115,13 @@ class DowntimesController extends Controller
|
|||
|
||||
$db = $this->getDb();
|
||||
|
||||
$downtimes = Downtime::on($db)->with([
|
||||
'host',
|
||||
'host.state',
|
||||
'service',
|
||||
'service.host',
|
||||
'service.host.state',
|
||||
'service.state'
|
||||
]);
|
||||
$downtimes = Downtime::on($db)
|
||||
->with('host')
|
||||
->with('host.state')
|
||||
->with('service')
|
||||
->with('service.host')
|
||||
->with('service.host.state')
|
||||
->with('service.state');
|
||||
|
||||
$this->filter($downtimes);
|
||||
|
||||
|
|
@ -148,14 +146,13 @@ class DowntimesController extends Controller
|
|||
|
||||
$db = $this->getDb();
|
||||
|
||||
$downtimes = Downtime::on($db)->with([
|
||||
'host',
|
||||
'host.state',
|
||||
'service',
|
||||
'service.host',
|
||||
'service.host.state',
|
||||
'service.state'
|
||||
]);
|
||||
$downtimes = Downtime::on($db)
|
||||
->with('host')
|
||||
->with('host.state')
|
||||
->with('service')
|
||||
->with('service.host')
|
||||
->with('service.host.state')
|
||||
->with('service.state');
|
||||
|
||||
$downtimes->limit(3)->peekAhead();
|
||||
|
||||
|
|
|
|||
|
|
@ -24,28 +24,26 @@ class EventController extends Controller
|
|||
$id = $this->params->getRequired('id');
|
||||
|
||||
$query = History::on($this->getDb())
|
||||
->with([
|
||||
'host',
|
||||
'host.state',
|
||||
'service',
|
||||
'service.state',
|
||||
'comment',
|
||||
'downtime',
|
||||
'downtime.parent',
|
||||
'downtime.parent.host',
|
||||
'downtime.parent.host.state',
|
||||
'downtime.parent.service',
|
||||
'downtime.parent.service.state',
|
||||
'downtime.triggered_by',
|
||||
'downtime.triggered_by.host',
|
||||
'downtime.triggered_by.host.state',
|
||||
'downtime.triggered_by.service',
|
||||
'downtime.triggered_by.service.state',
|
||||
'flapping',
|
||||
'notification',
|
||||
'acknowledgement',
|
||||
'state'
|
||||
])
|
||||
->with('host')
|
||||
->with('host.state')
|
||||
->with('service')
|
||||
->with('service.state')
|
||||
->with('comment')
|
||||
->with('downtime')
|
||||
->with('downtime.parent')
|
||||
->with('downtime.parent.host')
|
||||
->with('downtime.parent.host.state')
|
||||
->with('downtime.parent.service')
|
||||
->with('downtime.parent.service.state')
|
||||
->with('downtime.triggered_by')
|
||||
->with('downtime.triggered_by.host')
|
||||
->with('downtime.triggered_by.host.state')
|
||||
->with('downtime.triggered_by.service')
|
||||
->with('downtime.triggered_by.service.state')
|
||||
->with('flapping')
|
||||
->with('notification')
|
||||
->with('acknowledgement')
|
||||
->with('state')
|
||||
->filter(Filter::equal('id', hex2bin($id)));
|
||||
|
||||
$this->applyRestrictions($query);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class HealthController extends Controller
|
|||
|
||||
$db = $this->getDb();
|
||||
|
||||
$instance = Instance::on($db)->with(['endpoint']);
|
||||
$instance = Instance::on($db)->with('endpoint');
|
||||
$hoststateSummary = HoststateSummary::on($db)->with('state');
|
||||
$servicestateSummary = ServicestateSummary::on($db)->with('state');
|
||||
|
||||
|
|
|
|||
|
|
@ -24,18 +24,17 @@ class HistoryController extends Controller
|
|||
|
||||
$db = $this->getDb();
|
||||
|
||||
$history = History::on($db)->with([
|
||||
'host',
|
||||
'host.state',
|
||||
'service',
|
||||
'service.state',
|
||||
'comment',
|
||||
'downtime',
|
||||
'flapping',
|
||||
'notification',
|
||||
'acknowledgement',
|
||||
'state'
|
||||
]);
|
||||
$history = History::on($db)
|
||||
->with('host')
|
||||
->with('host.state')
|
||||
->with('service')
|
||||
->with('service.state')
|
||||
->with('comment')
|
||||
->with('downtime')
|
||||
->with('flapping')
|
||||
->with('notification')
|
||||
->with('acknowledgement')
|
||||
->with('state');
|
||||
|
||||
$before = $this->params->shift('before', time());
|
||||
$url = Url::fromPath('icingadb/history')->setParams(clone $this->params);
|
||||
|
|
|
|||
|
|
@ -40,8 +40,9 @@ class HostController extends Controller
|
|||
{
|
||||
$name = $this->params->getRequired('name');
|
||||
|
||||
$query = Host::on($this->getDb())->with(['state', 'icon_image']);
|
||||
$query
|
||||
$query = Host::on($this->getDb())
|
||||
->with('state')
|
||||
->with('icon_image')
|
||||
->setResultSetClass(VolatileStateResults::class)
|
||||
->filter(Filter::equal('host.name', $name));
|
||||
|
||||
|
|
@ -112,16 +113,15 @@ class HostController extends Controller
|
|||
|
||||
$db = $this->getDb();
|
||||
|
||||
$history = History::on($db)->with([
|
||||
'host',
|
||||
'host.state',
|
||||
'comment',
|
||||
'downtime',
|
||||
'flapping',
|
||||
'notification',
|
||||
'acknowledgement',
|
||||
'state'
|
||||
]);
|
||||
$history = History::on($db)
|
||||
->with('host')
|
||||
->with('host.state')
|
||||
->with('comment')
|
||||
->with('downtime')
|
||||
->with('flapping')
|
||||
->with('notification')
|
||||
->with('acknowledgement')
|
||||
->with('state');
|
||||
|
||||
$history->filter(Filter::all(
|
||||
Filter::equal('history.host_id', $this->host->id),
|
||||
|
|
@ -185,14 +185,12 @@ class HostController extends Controller
|
|||
|
||||
$db = $this->getDb();
|
||||
|
||||
$services = Service::on($db)->with([
|
||||
'state',
|
||||
'state.last_comment',
|
||||
'icon_image',
|
||||
'host',
|
||||
'host.state'
|
||||
]);
|
||||
$services
|
||||
$services = Service::on($db)
|
||||
->with('state')
|
||||
->with('state.last_comment')
|
||||
->with('icon_image')
|
||||
->with('host')
|
||||
->with('host.state')
|
||||
->setResultSetClass(VolatileStateResults::class)
|
||||
->filter(Filter::equal('host.id', $this->host->id));
|
||||
|
||||
|
|
|
|||
|
|
@ -49,10 +49,13 @@ class HostgroupController extends Controller
|
|||
{
|
||||
$db = $this->getDb();
|
||||
|
||||
$hosts = Host::on($db)->with(['state', 'state.last_comment', 'icon_image']);
|
||||
$hosts
|
||||
$hosts = Host::on($db)
|
||||
->with('state')
|
||||
->with('state.last_comment')
|
||||
->with('icon_image')
|
||||
->setResultSetClass(VolatileStateResults::class)
|
||||
->filter(Filter::equal('hostgroup.id', $this->hostgroup->id));
|
||||
|
||||
$this->applyRestrictions($hosts);
|
||||
|
||||
$limitControl = $this->createLimitControl();
|
||||
|
|
|
|||
|
|
@ -37,7 +37,10 @@ class HostsController extends Controller
|
|||
|
||||
$db = $this->getDb();
|
||||
|
||||
$hosts = Host::on($db)->with(['state', 'icon_image', 'state.last_comment']);
|
||||
$hosts = Host::on($db)
|
||||
->with('state')
|
||||
->with('icon_image')
|
||||
->with('state.last_comment');
|
||||
$hosts->getWith()['host.state']->setJoinType('INNER');
|
||||
$hosts->setResultSetClass(VolatileStateResults::class);
|
||||
|
||||
|
|
@ -127,9 +130,11 @@ 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']);
|
||||
$hosts = Host::on($db)
|
||||
->with('state')
|
||||
->with('icon_image')
|
||||
->setResultSetClass(VolatileStateResults::class);
|
||||
$summary = HoststateSummary::on($db);
|
||||
|
||||
$this->filter($hosts);
|
||||
$this->filter($summary);
|
||||
|
|
@ -142,12 +147,12 @@ class HostsController extends Controller
|
|||
$results = $hosts->execute();
|
||||
$summary = $summary->first();
|
||||
|
||||
$downtimes = Host::on($db)->with(['downtime']);
|
||||
$downtimes = Host::on($db)->with('downtime');
|
||||
$downtimes->getWith()['host.downtime']->setJoinType('INNER');
|
||||
$this->filter($downtimes);
|
||||
$summary->downtimes_total = $downtimes->count();
|
||||
|
||||
$comments = Host::on($db)->with(['comment']);
|
||||
$comments = Host::on($db)->with('comment');
|
||||
$comments->getWith()['host.comment']->setJoinType('INNER');
|
||||
// TODO: This should be automatically done by the model/resolver and added as ON condition
|
||||
$comments->filter(Filter::equal('comment.object_type', 'host'));
|
||||
|
|
|
|||
|
|
@ -25,13 +25,12 @@ class NotificationsController extends Controller
|
|||
|
||||
$db = $this->getDb();
|
||||
|
||||
$notifications = NotificationHistory::on($db)->with([
|
||||
'history',
|
||||
'host',
|
||||
'host.state',
|
||||
'service',
|
||||
'service.state'
|
||||
]);
|
||||
$notifications = NotificationHistory::on($db)
|
||||
->with('history')
|
||||
->with('host')
|
||||
->with('host.state')
|
||||
->with('service')
|
||||
->with('service.state');
|
||||
|
||||
$this->handleSearchRequest($notifications);
|
||||
$before = $this->params->shift('before', time());
|
||||
|
|
|
|||
|
|
@ -37,13 +37,11 @@ class ServiceController extends Controller
|
|||
$name = $this->params->getRequired('name');
|
||||
$hostName = $this->params->getRequired('host.name');
|
||||
|
||||
$query = Service::on($this->getDb())->with([
|
||||
'state',
|
||||
'icon_image',
|
||||
'host',
|
||||
'host.state'
|
||||
]);
|
||||
$query
|
||||
$query = Service::on($this->getDb())
|
||||
->with('state')
|
||||
->with('icon_image')
|
||||
->with('host')
|
||||
->with('host.state')
|
||||
->setResultSetClass(VolatileStateResults::class)
|
||||
->filter(Filter::all(
|
||||
Filter::equal('service.name', $name),
|
||||
|
|
@ -116,18 +114,18 @@ class ServiceController extends Controller
|
|||
|
||||
$db = $this->getDb();
|
||||
|
||||
$history = History::on($db)->with([
|
||||
'host',
|
||||
'host.state',
|
||||
'service',
|
||||
'service.state',
|
||||
'comment',
|
||||
'downtime',
|
||||
'flapping',
|
||||
'notification',
|
||||
'acknowledgement',
|
||||
'state'
|
||||
]);
|
||||
$history = History::on($db)
|
||||
->with('host')
|
||||
->with('host.state')
|
||||
->with('service')
|
||||
->with('service.state')
|
||||
->with('comment')
|
||||
->with('downtime')
|
||||
->with('flapping')
|
||||
->with('notification')
|
||||
->with('acknowledgement')
|
||||
->with('state');
|
||||
|
||||
$history->filter(Filter::all(
|
||||
Filter::equal('history.host_id', $this->service->host_id),
|
||||
Filter::equal('history.service_id', $this->service->id)
|
||||
|
|
|
|||
|
|
@ -48,14 +48,12 @@ class ServicegroupController extends Controller
|
|||
{
|
||||
$db = $this->getDb();
|
||||
|
||||
$services = Service::on($db)->with([
|
||||
'state',
|
||||
'state.last_comment',
|
||||
'icon_image',
|
||||
'host',
|
||||
'host.state'
|
||||
]);
|
||||
$services
|
||||
$services = Service::on($db)
|
||||
->with('state')
|
||||
->with('state.last_comment')
|
||||
->with('icon_image')
|
||||
->with('host')
|
||||
->with('host.state')
|
||||
->setResultSetClass(VolatileStateResults::class)
|
||||
->filter(Filter::equal('servicegroup.id', $this->servicegroup->id));
|
||||
|
||||
|
|
|
|||
|
|
@ -40,13 +40,12 @@ class ServicesController extends Controller
|
|||
|
||||
$db = $this->getDb();
|
||||
|
||||
$services = Service::on($db)->with([
|
||||
'state',
|
||||
'state.last_comment',
|
||||
'host',
|
||||
'host.state',
|
||||
'icon_image'
|
||||
]);
|
||||
$services = Service::on($db)
|
||||
->with('state')
|
||||
->with('state.last_comment')
|
||||
->with('host')
|
||||
->with('host.state')
|
||||
->with('icon_image');
|
||||
$services->getWith()['service.state']->setJoinType('INNER');
|
||||
$services->setResultSetClass(VolatileStateResults::class);
|
||||
|
||||
|
|
@ -137,14 +136,13 @@ class ServicesController extends Controller
|
|||
|
||||
$db = $this->getDb();
|
||||
|
||||
$services = Service::on($db)->with([
|
||||
'state',
|
||||
'icon_image',
|
||||
'host',
|
||||
'host.state'
|
||||
]);
|
||||
$services->setResultSetClass(VolatileStateResults::class);
|
||||
$summary = ServicestateSummary::on($db)->with(['state']);
|
||||
$services = Service::on($db)
|
||||
->with('state')
|
||||
->with('icon_image')
|
||||
->with('host')
|
||||
->with('host.state')
|
||||
->setResultSetClass(VolatileStateResults::class);
|
||||
$summary = ServicestateSummary::on($db);
|
||||
|
||||
$this->filter($services);
|
||||
$this->filter($summary);
|
||||
|
|
@ -157,12 +155,12 @@ class ServicesController extends Controller
|
|||
$results = $services->execute();
|
||||
$summary = $summary->first();
|
||||
|
||||
$downtimes = Service::on($db)->with(['downtime']);
|
||||
$downtimes = Service::on($db)->with('downtime');
|
||||
$downtimes->getWith()['service.downtime']->setJoinType('INNER');
|
||||
$this->filter($downtimes);
|
||||
$summary->downtimes_total = $downtimes->count();
|
||||
|
||||
$comments = Service::on($db)->with(['comment']);
|
||||
$comments = Service::on($db)->with('comment');
|
||||
$comments->getWith()['service.comment']->setJoinType('INNER');
|
||||
// TODO: This should be automatically done by the model/resolver and added as ON condition
|
||||
$comments->filter(Filter::equal('comment.object_type', 'service'));
|
||||
|
|
@ -365,12 +363,11 @@ class ServicesController extends Controller
|
|||
{
|
||||
$db = $this->getDb();
|
||||
|
||||
$services = Service::on($db)->with([
|
||||
'state',
|
||||
'host',
|
||||
'host.state'
|
||||
]);
|
||||
$services->setResultSetClass(VolatileStateResults::class);
|
||||
$services = Service::on($db)
|
||||
->with('state')
|
||||
->with('host')
|
||||
->with('host.state')
|
||||
->setResultSetClass(VolatileStateResults::class);
|
||||
|
||||
switch ($this->getRequest()->getActionName()) {
|
||||
case 'acknowledge':
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class ApplicationState extends ApplicationStateHook
|
|||
public function collectMessages()
|
||||
{
|
||||
$instance = Instance::on($this->getDb())
|
||||
->with(['endpoint'])
|
||||
->with('endpoint')
|
||||
->filter(Filter::equal('responsible', true))
|
||||
->orderBy('heartbeat', 'desc')
|
||||
->first();
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ class IcingaHealth extends HealthHook
|
|||
{
|
||||
if ($this->instance === null) {
|
||||
$this->instance = Instance::on($this->getDb())
|
||||
->with('endpoint')
|
||||
->with('endpoint', ['name'])
|
||||
->columns([
|
||||
'heartbeat',
|
||||
'responsible',
|
||||
|
|
@ -77,8 +77,7 @@ class IcingaHealth extends HealthHook
|
|||
'icinga2_notifications_enabled',
|
||||
'icinga2_performance_data_enabled',
|
||||
'icinga2_start_time',
|
||||
'icinga2_version',
|
||||
'endpoint.name'
|
||||
'icinga2_version'
|
||||
])
|
||||
->first();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,14 +163,13 @@ class DowntimeDetail extends BaseHtmlElement
|
|||
));
|
||||
}
|
||||
|
||||
$query = Downtime::on($this->getDb())->with([
|
||||
'host',
|
||||
'host.state',
|
||||
'service',
|
||||
'service.host',
|
||||
'service.host.state',
|
||||
'service.state'
|
||||
])
|
||||
$query = Downtime::on($this->getDb())
|
||||
->with('host')
|
||||
->with('host.state')
|
||||
->with('service')
|
||||
->with('service.host')
|
||||
->with('service.host.state')
|
||||
->with('service.state')
|
||||
->limit(3)
|
||||
->filter(Filter::equal('parent_id', $this->downtime->id))
|
||||
->orFilter(Filter::equal('triggered_by_id', $this->downtime->id));
|
||||
|
|
|
|||
Loading…
Reference in a new issue