mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Refactored Alert schedule (#9514)
* add AlertSchedule model and relationships change table structure to match the expected layout * Update maint schedule map ui * better index name * Laravel queries fix some issues with the ui: restricting start incorrectly and loading empty days error * handle date limiting properly * Another attempt add schedule constraints * use Auth * Update WorldMap widget to use check isUnderMaintenance * Rename 275.sql to 276.sql * Rename 276.sql to 277.sql
This commit is contained in:
committed by
Neil Lathwood
parent
0cc599c576
commit
f10cbddacc
@@ -150,19 +150,12 @@ function GetRules($device_id)
|
||||
|
||||
/**
|
||||
* Check if device is under maintenance
|
||||
* @param int $device Device-ID
|
||||
* @return int
|
||||
* @param int $device_id Device-ID
|
||||
* @return bool
|
||||
*/
|
||||
function IsMaintenance($device)
|
||||
function IsMaintenance($device_id)
|
||||
{
|
||||
$groups = GetGroupsFromDevice($device);
|
||||
$params = array($device);
|
||||
$where = "";
|
||||
foreach ($groups as $group) {
|
||||
$where .= " || alert_schedule_items.target = ?";
|
||||
$params[] = 'g'.$group;
|
||||
}
|
||||
return dbFetchCell('SELECT alert_schedule.schedule_id FROM alert_schedule LEFT JOIN alert_schedule_items ON alert_schedule.schedule_id=alert_schedule_items.schedule_id WHERE ( alert_schedule_items.target = ?'.$where.' ) && ((alert_schedule.recurring = 0 AND (NOW() BETWEEN alert_schedule.start AND alert_schedule.end)) OR (alert_schedule.recurring = 1 AND (alert_schedule.start_recurring_dt <= date_format(NOW(), \'%Y-%m-%d\') AND (end_recurring_dt >= date_format(NOW(), \'%Y-%m-%d\') OR end_recurring_dt is NULL OR end_recurring_dt = \'0000-00-00\' OR end_recurring_dt = \'\')) AND (date_format(now(), \'%H:%i:%s\') BETWEEN `start_recurring_hr` AND end_recurring_hr) AND (recurring_day LIKE CONCAT(\'%\',date_format(now(), \'%w\'),\'%\') OR recurring_day is null or recurring_day = \'\'))) LIMIT 1', $params);
|
||||
return \App\Models\Device::find($device_id)->isUnderMaintenance();
|
||||
}
|
||||
/**
|
||||
* Run all rules for a device
|
||||
|
Reference in New Issue
Block a user