-
Notifications
You must be signed in to change notification settings - Fork 209
Fix Command Inheritance not shown #3007 #3009
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fix Command Inheritance not shown #3007 #3009
Conversation
| $query = $this->db->select()->from(array('c' => 'icinga_' . $table), $columns)->join(array('ici' => 'icinga_command_inheritance'), | ||
| 'ici.command_id = c.id', | ||
| array()); | ||
|
|
||
| foreach ($rels as $rel) { | ||
| $query->orWhere("parent_{$rel}_id = ?", $id); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| $query = $this->db->select()->from(array('c' => 'icinga_' . $table), $columns)->join(array('ici' => 'icinga_command_inheritance'), | |
| 'ici.command_id = c.id', | |
| array()); | |
| foreach ($rels as $rel) { | |
| $query->orWhere("parent_{$rel}_id = ?", $id); | |
| } | |
| $query = $this->db->select()->from(['c' => 'icinga_' . $table], $columns)->join( | |
| ['ici' => 'icinga_command_inheritance'], | |
| 'ici.command_id = c.id', | |
| [] | |
| )->where('ici.parent_command_id = ?', $id); |
IMO, you could rewrite the where as suggested, just makes it a bit easier to understand the code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems not to be resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would render the $rels var useless, and might break something else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The $rels variable comes from the $map variable. You could give an empty array there, as the relation in the map is basically used to build the column {rel}_id to filter the objects. And since for command you filter its inheritance table. You could directly filter it in the query.
Or you could do the below, where you add the join and the filter to the query only if the table is 'command', and everything remains same. This solution also results in minimal changes to the existing code. You should still give empty array for command ('command' => []) in $map variable. Also, looking at it again I find this solution better.
$query = $this->db->select()->from(['c' => "icinga_$table"], $columns);
if ($table === "command") {
$query->join(
['ici' => 'icinga_command_inheritance'],
'ici.command_id = c.id',
[]
)->where('ici.parent_command_id = ?', $id);
}
foreach ($rels as $rel) {
$query->orWhere("{$rel}_id = ?", $id);
}Co-authored-by: Ravi Kumar Kempapura Srinivasa <[email protected]>
| $query = $this->db->select()->from(array('c' => 'icinga_' . $table), $columns)->join(array('ici' => 'icinga_command_inheritance'), | ||
| 'ici.command_id = c.id', | ||
| array()); | ||
|
|
||
| foreach ($rels as $rel) { | ||
| $query->orWhere("parent_{$rel}_id = ?", $id); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems not to be resolved
Co-authored-by: Ravi Kumar Kempapura Srinivasa <[email protected]>
| $query = $this->db->select()->from(array('c' => 'icinga_' . $table), $columns)->join(array('ici' => 'icinga_command_inheritance'), | ||
| 'ici.command_id = c.id', | ||
| array()); | ||
|
|
||
| foreach ($rels as $rel) { | ||
| $query->orWhere("parent_{$rel}_id = ?", $id); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The $rels variable comes from the $map variable. You could give an empty array there, as the relation in the map is basically used to build the column {rel}_id to filter the objects. And since for command you filter its inheritance table. You could directly filter it in the query.
Or you could do the below, where you add the join and the filter to the query only if the table is 'command', and everything remains same. This solution also results in minimal changes to the existing code. You should still give empty array for command ('command' => []) in $map variable. Also, looking at it again I find this solution better.
$query = $this->db->select()->from(['c' => "icinga_$table"], $columns);
if ($table === "command") {
$query->join(
['ici' => 'icinga_command_inheritance'],
'ici.command_id = c.id',
[]
)->where('ici.parent_command_id = ?', $id);
}
foreach ($rels as $rel) {
$query->orWhere("{$rel}_id = ?", $id);
}| 'host' => ['check_command', 'event_command'], | ||
| 'service' => ['check_command', 'event_command'], | ||
| 'notification' => ['command'], | ||
| 'command' => ['command'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 'command' => ['command'], | |
| 'command' => [], |
This could be an empty array, as this is basically used to build the command id column for the table to filter the objects using the corresponding command.
shows commands and command templates and filters by commandname in the table views
Best Regards
Nicolas