Merge pull request #21 from Icinga/fix/inefficient-history-joins

Fix inefficient history joins
This commit is contained in:
Johannes Meyer 2020-03-02 10:17:13 +01:00 committed by GitHub
commit d3dec9b85b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 12 additions and 18 deletions

View file

@ -22,8 +22,6 @@ class HistoryController extends Controller
'host.state',
'service',
'service.state',
'service.host',
'service.host.state',
'comment',
'downtime',
'notification',

View file

@ -21,8 +21,6 @@ class NotificationsController extends Controller
'host',
'host.state',
'service',
'service.host',
'service.host.state',
'service.state'
]);

View file

@ -121,8 +121,6 @@ class ServiceController extends Controller
'host.state',
'service',
'service.state',
'service.host',
'service.host.state',
'comment',
'downtime',
'notification',

View file

@ -57,7 +57,7 @@ class CommentHistory extends Model
{
$relations->belongsTo('endpoint', Endpoint::class);
$relations->belongsTo('environment', Environment::class);
$relations->belongsTo('host', Host::class)->setJoinType('LEFT');
$relations->belongsTo('service', Service::class)->setJoinType('LEFT');
$relations->belongsTo('host', Host::class);
$relations->belongsTo('service', Service::class);
}
}

View file

@ -68,7 +68,7 @@ class DowntimeHistory extends Model
// @TODO(el): Add relation for triggered_by_id
$relations->belongsTo('endpoint', Endpoint::class);
$relations->belongsTo('environment', Environment::class);
$relations->belongsTo('host', Host::class)->setJoinType('LEFT');
$relations->belongsTo('service', Service::class)->setJoinType('LEFT');
$relations->belongsTo('host', Host::class);
$relations->belongsTo('service', Service::class);
}
}

View file

@ -59,8 +59,8 @@ class History extends Model
// @TODO(el): Add relation for flapping_history_id
$relations->belongsTo('endpoint', Endpoint::class);
$relations->belongsTo('environment', Environment::class);
$relations->belongsTo('host', Host::class)->setJoinType('LEFT');
$relations->belongsTo('service', Service::class)->setJoinType('LEFT');
$relations->belongsTo('host', Host::class);
$relations->belongsTo('service', Service::class);
$relations->belongsTo('comment', CommentHistory::class)
->setCandidateKey('comment_history_id')
->setForeignKey('comment_id')

View file

@ -58,7 +58,7 @@ class NotificationHistory extends Model
public function createRelations(Relations $relations)
{
$relations->belongsTo('environment', Environment::class);
$relations->belongsTo('host', Host::class)->setJoinType('LEFT');
$relations->belongsTo('service', Service::class)->setJoinType('LEFT');
$relations->belongsTo('host', Host::class);
$relations->belongsTo('service', Service::class);
}
}

View file

@ -52,7 +52,7 @@ class StateHistory extends Model
{
$relations->belongsTo('endpoint', Endpoint::class);
$relations->belongsTo('environment', Environment::class);
$relations->belongsTo('host', Host::class)->setJoinType('LEFT');
$relations->belongsTo('service', Service::class)->setJoinType('LEFT');
$relations->belongsTo('host', Host::class);
$relations->belongsTo('service', Service::class);
}
}

View file

@ -166,7 +166,7 @@ class HistoryListItem extends CommonListItem
if ($this->item->object_type === 'host') {
$link = $this->createHostLink($this->item->host, true);
} else {
$link = $this->createServiceLink($this->item->service, $this->item->service->host, true);
$link = $this->createServiceLink($this->item->service, $this->item->host, true);
}
$title->add([Html::tag('br'), $link]);

View file

@ -105,7 +105,7 @@ class NotificationListItem extends CommonListItem
if ($this->item->object_type === 'host') {
$link = $this->createHostLink($this->item->host, true);
} else {
$link = $this->createServiceLink($this->item->service, $this->item->service->host, true);
$link = $this->createServiceLink($this->item->service, $this->item->host, true);
}
$title->add($link);