icingadb-web/library/Icingadb/Model/NotificationHistory.php
Johannes Meyer 9fc88e28c6 Join hosts and services with an INNER join in history queries
Otherwise history entries of removed objects are fetched.
2020-02-07 15:50:55 +01:00

64 lines
1.4 KiB
PHP

<?php
namespace Icinga\Module\Icingadb\Model;
use Icinga\Module\Icingadb\Model\Behavior\ReRoute;
use Icinga\Module\Icingadb\Model\Behavior\Timestamp;
use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
class NotificationHistory extends Model
{
public function getTableName()
{
return 'notification_history';
}
public function getKeyName()
{
return 'id';
}
public function getColumns()
{
return [
'environment_id',
'endpoint_id',
'object_type',
'host_id',
'service_id',
'notification_id',
'type',
'send_time',
'state',
'previous_hard_state',
'author',
'text',
'users_notified'
];
}
public function getDefaultSort()
{
return 'notification_history.send_time desc';
}
public function createBehaviors(Behaviors $behaviors)
{
$behaviors->add(new Timestamp([
'send_time'
]));
$behaviors->add(new ReRoute([
'hostgroup' => 'host.hostgroup',
'servicegroup' => 'service.servicegroup'
]));
}
public function createRelations(Relations $relations)
{
$relations->belongsTo('environment', Environment::class);
$relations->belongsTo('host', Host::class);
$relations->belongsTo('service', Service::class);
}
}