mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-05-28 04:36:06 -04:00
Fix failed to resolve reversed host/service -> comment relations (#858)
fixes #827
This commit is contained in:
commit
cacc770ce5
6 changed files with 41 additions and 9 deletions
|
|
@ -108,13 +108,7 @@ class Comment extends Model
|
|||
{
|
||||
$relations->belongsTo('environment', Environment::class);
|
||||
$relations->belongsTo('host', Host::class)->setJoinType('LEFT');
|
||||
$relations->belongsTo('host_state', HostState::class)
|
||||
->setForeignKey('last_comment_id')
|
||||
->setCandidateKey('id');
|
||||
$relations->belongsTo('service', Service::class)->setJoinType('LEFT');
|
||||
$relations->belongsTo('service_state', ServiceState::class)
|
||||
->setForeignKey('last_comment_id')
|
||||
->setCandidateKey('id');
|
||||
$relations->belongsTo('zone', Zone::class);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class HostState extends State
|
|||
{
|
||||
$relations->belongsTo('environment', Environment::class);
|
||||
$relations->belongsTo('host', Host::class);
|
||||
$relations->hasOne('last_comment', Comment::class)
|
||||
$relations->hasOne('last_comment', LastHostComment::class)
|
||||
->setCandidateKey('last_comment_id')
|
||||
->setForeignKey('id')
|
||||
->setJoinType('LEFT');
|
||||
|
|
|
|||
19
library/Icingadb/Model/LastHostComment.php
Normal file
19
library/Icingadb/Model/LastHostComment.php
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
/* Icinga DB Web | (c) 2023 Icinga GmbH | GPLv2 */
|
||||
|
||||
namespace Icinga\Module\Icingadb\Model;
|
||||
|
||||
use ipl\Orm\Relations;
|
||||
|
||||
class LastHostComment extends Comment
|
||||
{
|
||||
public function createRelations(Relations $relations): void
|
||||
{
|
||||
$relations->belongsTo('environment', Environment::class);
|
||||
$relations->belongsTo('zone', Zone::class);
|
||||
$relations->belongsTo('state', HostState::class)
|
||||
->setForeignKey('last_comment_id')
|
||||
->setCandidateKey('id');
|
||||
}
|
||||
}
|
||||
19
library/Icingadb/Model/LastServiceComment.php
Normal file
19
library/Icingadb/Model/LastServiceComment.php
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
/* Icinga DB Web | (c) 2023 Icinga GmbH | GPLv2 */
|
||||
|
||||
namespace Icinga\Module\Icingadb\Model;
|
||||
|
||||
use ipl\Orm\Relations;
|
||||
|
||||
class LastServiceComment extends Comment
|
||||
{
|
||||
public function createRelations(Relations $relations): void
|
||||
{
|
||||
$relations->belongsTo('environment', Environment::class);
|
||||
$relations->belongsTo('zone', Zone::class);
|
||||
$relations->belongsTo('state', ServiceState::class)
|
||||
->setForeignKey('last_comment_id')
|
||||
->setCandidateKey('id');
|
||||
}
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ class ServiceState extends State
|
|||
{
|
||||
$relations->belongsTo('environment', Environment::class);
|
||||
$relations->belongsTo('service', Service::class);
|
||||
$relations->hasOne('last_comment', Comment::class)
|
||||
$relations->hasOne('last_comment', LastServiceComment::class)
|
||||
->setCandidateKey('last_comment_id')
|
||||
->setForeignKey('id')
|
||||
->setJoinType('LEFT');
|
||||
|
|
|
|||
|
|
@ -387,7 +387,7 @@ class ObjectSuggestions extends Suggestions
|
|||
/** @var Relation $relation */
|
||||
if (
|
||||
empty($path) || (
|
||||
$name === 'state'
|
||||
($name === 'state' && $path[count($path) - 1] !== 'last_comment')
|
||||
|| $name === 'last_comment'
|
||||
|| $name === 'notificationcommand' && $path[0] === 'notification'
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue