fix misc bugs
This commit is contained in:
parent
c027e56dd0
commit
efba28f3f4
12
oncall.php
12
oncall.php
@ -4,12 +4,11 @@ declare(strict_types = 1);
|
|||||||
require_once 'vendor/autoload.php';
|
require_once 'vendor/autoload.php';
|
||||||
|
|
||||||
use Yasumi\Holiday;
|
use Yasumi\Holiday;
|
||||||
|
|
||||||
/* On Call Ticket Notification Script */
|
/* On Call Ticket Notification Script */
|
||||||
$oncall = new oncall();
|
$oncall = new oncall();
|
||||||
$oncall->dateAndTimeCheck();
|
$oncall->dateAndTimeCheck();
|
||||||
$oncall->retrieveItems();
|
$oncall->retrieveItems();
|
||||||
if (!$this->notify) {
|
if (!$oncall->notify) {
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
$oncall->setEmail();
|
$oncall->setEmail();
|
||||||
@ -71,7 +70,7 @@ class oncall {
|
|||||||
* A flag of whether Mattermost should be contacted.
|
* A flag of whether Mattermost should be contacted.
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
private $notify;
|
public $notify;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
// Load the .env file
|
// Load the .env file
|
||||||
@ -107,7 +106,8 @@ class oncall {
|
|||||||
if ($td_min > 60) {
|
if ($td_min > 60) {
|
||||||
$this->everyone = TRUE;
|
$this->everyone = TRUE;
|
||||||
}
|
}
|
||||||
if ($td_min < 3 || ($td_min >= 30 || $td_min < 33)) {
|
// Notify every 30 minutes.
|
||||||
|
if (($td_min % 30) < 3) {
|
||||||
$this->notify = TRUE;
|
$this->notify = TRUE;
|
||||||
}
|
}
|
||||||
return $td_min;
|
return $td_min;
|
||||||
@ -201,7 +201,7 @@ class oncall {
|
|||||||
|
|
||||||
public function setEmail() {
|
public function setEmail() {
|
||||||
// path to file containing email of person on call
|
// path to file containing email of person on call
|
||||||
$contactfile = './contact.txt';
|
$contactfile = __DIR__ . "/contact.txt";
|
||||||
// set the email of the person on call
|
// set the email of the person on call
|
||||||
$this->email = trim(file_get_contents("$contactfile"));
|
$this->email = trim(file_get_contents("$contactfile"));
|
||||||
}
|
}
|
||||||
@ -210,7 +210,7 @@ class oncall {
|
|||||||
* Checks whether we're responsible for on-call on this date and time.
|
* Checks whether we're responsible for on-call on this date and time.
|
||||||
*/
|
*/
|
||||||
public function dateAndTimeCheck() {
|
public function dateAndTimeCheck() {
|
||||||
$today = new DateTime();
|
$today = new DateTime("now", new DateTimeZone('America/New_York'));
|
||||||
$thisYear = (int) $today->format('Y');
|
$thisYear = (int) $today->format('Y');
|
||||||
$thisHour = (int) $today->format('H');
|
$thisHour = (int) $today->format('H');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user