Permalink
Browse files

Add an effective period to the checks (sql script)

4 columns was added in the checks table to define
start/end time and start/end day for a check so that the application
won't notify the users if an alert happens outside of this period.
It can be usefull to not monitor data during the night and the week end
or other applications...
  • Loading branch information...
Florent Couffe
Florent Couffe committed Jun 14, 2013
1 parent 4389b71 commit 0209eeb3c7a7c2bd0d75b255a115d40c0a4e8dad
@@ -56,6 +56,27 @@
$check = new Check($check_id);
if (fRequest::isPost()) {
$check->populate();
$period = fRequest::get('all_the_time_or_period');
$hourStart = NULL;
$hourEnd = NULL;
$dayStart = NULL;
$dayEnd = NULL;
if ('period' == $period) {
if (!fRequest::check("no_time_filter")) {
$hourStart = fRequest::get('start_hr').":".fRequest::get('start_min');
$hourEnd = fRequest::get('end_hr').":".fRequest::get('end_min');
}
if (!fRequest::check("no_day_filter")) {
$dayStart = fRequest::get('start_day');
$dayEnd = fRequest::get('end_day');
}
}
$check->setHourStart($hourStart);
$check->setHourEnd($hourEnd);
$check->setDayStart($dayStart);
$check->setDayEnd($dayEnd);
fRequest::validateCSRFToken(fRequest::get('token'));
$check->store();
@@ -83,6 +104,35 @@
if (fRequest::isPost()) {
try {
$check->populate();
$period = fRequest::get('all_the_time_or_period');
$hourStart = NULL;
$hourEnd = NULL;
$dayStart = NULL;
$dayEnd = NULL;
if ('period' == $period) {
if (!fRequest::check("no_time_filter")) {
$hourStart = fRequest::get('start_hr').":".fRequest::get('start_min');
$hourEnd = fRequest::get('end_hr').":".fRequest::get('end_min');
if ($hourStart == $hourEnd) {
$hourStart = NULL;
$hourEnd = NULL;
}
}
if (!fRequest::check("no_day_filter")) {
$dayStart = fRequest::get('start_day');
$dayEnd = fRequest::get('end_day');
if ($dayStart == $dayEnd) {
$dayStart = NULL;
$dayEnd = NULL;
}
}
}
$check->setHourStart($hourStart);
$check->setHourEnd($hourEnd);
$check->setDayStart($dayStart);
$check->setDayEnd($dayEnd);
fRequest::validateCSRFToken(fRequest::get('token'));
$check->store();
@@ -55,6 +55,10 @@ CREATE TABLE `checks` (
`regression_type` varchar(255) DEFAULT NULL,
`number_of_regressions` int(11) DEFAULT NULL,
`group_id` int(11) NOT NULL DEFAULT '1',
`hour_start` varchar(5) DEFAULT NULL;
`hour_end` varchar(5) DEFAULT NULL;
`day_start` varchar(3) DEFAULT NULL;
`day_end` varchar(3) DEFAULT NULL;
PRIMARY KEY (`check_id`),
UNIQUE KEY `user_id` (`user_id`,`name`)
) CHARSET=utf8;
@@ -1085,6 +1085,11 @@ public function modify($format, $timezone=NULL)
$timezone = ($timezone !== NULL) ? $timezone : $this->timezone;
return new fTimestamp($this->format($format), $timezone);
}
public function date ($format) {
return date($format,$this->timestamp);
}
}
@@ -158,4 +158,23 @@ function addOrReplaceInURL ($url, $key=NULL, $value=NULL) {
}
return $url;
}
/**
* The parameters should be in format : "hh:mm"
*/
function compare_hours ($hour1,$hour2) {
if ($hour1 == $hour2) {
return 0;
} else {
$array_hour1 = explode(":", $hour1);
$array_hour2 = explode(":", $hour2);
if ($array_hour1[0] > $array_hour2[0]) {
return 1;
} else if ($array_hour1[0] < $array_hour2[0]) {
return -1;
} else {
return (($array_hour1[1] > $array_hour2[1])?1:-1);
}
}
}
?>
Oops, something went wrong.

0 comments on commit 0209eeb

Please sign in to comment.