From dc05d9ddaf94f669b45e342361c4905f090459f3 Mon Sep 17 00:00:00 2001 From: drigato Date: Tue, 17 Dec 2013 17:09:59 -0500 Subject: [PATCH 1/7] CC-5649: Remove unused function, Application_Model_Show::populateAllShowsInRange --- airtime_mvc/application/models/Show.php | 35 ------------------------- 1 file changed, 35 deletions(-) diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index 4271d2d55..e5daff311 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -920,41 +920,6 @@ SQL; ->save(); } - /** - * Generate all the repeating shows in the given range. - * - * @param DateTime $p_startTimestamp - * In UTC format. - * @param DateTime $p_endTimestamp - * In UTC format. - */ - public static function populateAllShowsInRange($p_startTimestamp, $p_endTimestamp) - { - $con = Propel::getConnection(); - - $endTimeString = $p_endTimestamp->format("Y-m-d H:i:s"); - if (!is_null($p_startTimestamp)) { - $startTimeString = $p_startTimestamp->format("Y-m-d H:i:s"); - } else { - $today_timestamp = new DateTime("now", new DateTimeZone("UTC")); - $startTimeString = $today_timestamp->format("Y-m-d H:i:s"); - } - - $stmt = $con->prepare(" - SELECT * FROM cc_show_days - WHERE last_show IS NULL - OR first_show < :endTimeString AND last_show > :startTimeString"); - - $stmt->bindParam(':endTimeString', $endTimeString); - $stmt->bindParam(':startTimeString', $startTimeString); - $stmt->execute(); - - $res = $stmt->fetchAll(); - foreach ($res as $row) { - Application_Model_Show::populateShow($row, $p_endTimestamp); - } - } - /** * * @param DateTime $start From c5a6e816909727f8a6be43a9d3b18430b7cc0bf8 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Mon, 6 Jan 2014 11:31:18 +0000 Subject: [PATCH 2/7] SAAS-374 Don't expose API key when a component has failed --- utils/airtime-check-system.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/utils/airtime-check-system.php b/utils/airtime-check-system.php index 1ce017c35..3a4816dcf 100644 --- a/utils/airtime-check-system.php +++ b/utils/airtime-check-system.php @@ -221,10 +221,7 @@ class AirtimeCheck { } public static function show_log_file($log) { - exec("tail -5 $log", $output); - self::output_comment("Displaying log file $log"); - self::output_comment($output); - self::output_comment(""); + self::output_comment("Check the log file $log"); self::output_comment(""); } From 11284d0d4181b09359618c301475005dd5292ac9 Mon Sep 17 00:00:00 2001 From: drigato Date: Mon, 6 Jan 2014 13:51:06 -0500 Subject: [PATCH 3/7] CC-5660: Unable to create shows with a rebroadcast Two variables that are needed for the rebroadcast validation were deleted before the 2.5.1 release. Just had to add them back in. --- airtime_mvc/application/forms/AddShowWhen.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/airtime_mvc/application/forms/AddShowWhen.php b/airtime_mvc/application/forms/AddShowWhen.php index 91259400a..ff92d7c60 100644 --- a/airtime_mvc/application/forms/AddShowWhen.php +++ b/airtime_mvc/application/forms/AddShowWhen.php @@ -162,6 +162,13 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm } + /* We need to know the show duration broken down into hours and minutes + * They are used for checking overlapping shows and for validating + * rebroadcast instances + */ + $hours = $duration->format("%h"); + $minutes = $duration->format("%m"); + /* Check if show is overlapping * We will only do this check if the show is valid * upto this point From 2cdad4932afd095322fe72fd7ac340495452782c Mon Sep 17 00:00:00 2001 From: drigato Date: Mon, 6 Jan 2014 14:04:18 -0500 Subject: [PATCH 4/7] CC-5660: Unable to create shows with a rebroadcast Used wrong formating for minutes --- airtime_mvc/application/forms/AddShowWhen.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airtime_mvc/application/forms/AddShowWhen.php b/airtime_mvc/application/forms/AddShowWhen.php index ff92d7c60..9644535b9 100644 --- a/airtime_mvc/application/forms/AddShowWhen.php +++ b/airtime_mvc/application/forms/AddShowWhen.php @@ -167,7 +167,7 @@ class Application_Form_AddShowWhen extends Zend_Form_SubForm * rebroadcast instances */ $hours = $duration->format("%h"); - $minutes = $duration->format("%m"); + $minutes = $duration->format("%i"); /* Check if show is overlapping * We will only do this check if the show is valid From a648f7fa2d412094205b36fe657f016035ff011f Mon Sep 17 00:00:00 2001 From: drigato Date: Thu, 9 Jan 2014 11:57:32 -0500 Subject: [PATCH 5/7] CC-5665: Timeout can occur when scheduling large playlists into linked shows Added a temporary fix by extending the php time limit --- airtime_mvc/application/models/Scheduler.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/airtime_mvc/application/models/Scheduler.php b/airtime_mvc/application/models/Scheduler.php index 9cb79927c..01a12d1a1 100644 --- a/airtime_mvc/application/models/Scheduler.php +++ b/airtime_mvc/application/models/Scheduler.php @@ -515,6 +515,9 @@ class Application_Model_Scheduler private function insertAfter($scheduleItems, $mediaItems, $filesToInsert=null, $adjustSched=true, $moveAction=false) { try { + // temporary fix for CC-5665 + set_time_limit(180); + $affectedShowInstances = array(); //dont want to recalculate times for moved items From 9e5cfe0d39b31f4b290563e543fe0fdb7b577de2 Mon Sep 17 00:00:00 2001 From: drigato Date: Mon, 13 Jan 2014 11:41:44 -0500 Subject: [PATCH 6/7] CC-5666: Deleting a show instance can revert the 'no end' option --- .../application/services/ShowService.php | 127 +++++++++++------- 1 file changed, 77 insertions(+), 50 deletions(-) diff --git a/airtime_mvc/application/services/ShowService.php b/airtime_mvc/application/services/ShowService.php index 183af4723..d8a7651a4 100644 --- a/airtime_mvc/application/services/ShowService.php +++ b/airtime_mvc/application/services/ShowService.php @@ -667,11 +667,7 @@ SQL; $showId = $ccShowInstance->getDbShowId(); if ($singleInstance) { - $ccShowInstances = CcShowInstancesQuery::create() - ->filterByDbShowId($showId) - ->filterByDbStarts($ccShowInstance->getDbStarts(), Criteria::GREATER_EQUAL) - ->filterByDbEnds($ccShowInstance->getDbEnds(), Criteria::LESS_EQUAL) - ->find(); + $ccShowInstances = array($ccShowInstance); } else { $ccShowInstances = CcShowInstancesQuery::create() ->filterByDbShowId($showId) @@ -680,7 +676,9 @@ SQL; } if (gmdate("Y-m-d H:i:s") <= $ccShowInstance->getDbEnds()) { - $this->deleteShowInstances($ccShowInstances, $ccShowInstance->getDbShowId()); + $this->deleteShowInstances($ccShowInstances, $showId); + } else { + throw new Exception("Cannot delete a show instance in the past"); } Application_Model_StoredFile::updatePastFilesIsScheduled(); @@ -688,6 +686,7 @@ SQL; Application_Model_RabbitMq::PushSchedule(); $con->commit(); + return $showId; } catch (Exception $e) { $con->rollback(); @@ -723,6 +722,78 @@ SQL; CcShowQuery::create() ->filterByDbId($showId) ->delete(); + /* There is only one cc_show_instance if the user selects 'Delete This Instance' + * There is more than one cc_show_instance if the user selects 'Delete This + * Instance and All Following'. We only need to set the last_show value + * when 'Delete This Instance and All Following' has been selected + */ + } elseif (count($ccShowInstances) > 1) { + $this->setLastRepeatingShowDate($showId); + } + } + + private function setLastRepeatingShowDate($showId) + { + $ccShowInstances = CcShowInstancesQuery::create() + ->filterByDbShowId($showId) + ->filterByDbModifiedInstance(false) + ->filterByDbRebroadcast(0) + ->orderByDbStarts() + ->find(); + + /* We need to update the last_show in cc_show_days so the instances + * don't get recreated as the user moves forward in the calendar + */ + $lastShowDays = array(); + + //get the show's timezone + $ccShow = CcShowQuery::create()->findPk($showId); + if ($ccShow->isRepeating()) { + $showTimezone = $ccShow->getFirstRepeatingCcShowDay()->getDbTimezone(); + } else { + $showTimezone = $ccShow->getFirstCcShowDay()->getDbTimezone(); + } + + /* Creates an array where the key is the day of the week (monday, + * tuesday, etc.) and the value is the last show date for each + * day of the week. We will use this array to update the last_show + * for each cc_show_days entry of a cc_show + */ + foreach ($ccShowInstances as $instance) { + $instanceStartDT = $instance->getDbStarts(null); + $instanceStartDT->setTimezone(new DateTimeZone($showTimezone)); + $lastShowDays[$instanceStartDT->format("w")] = $instanceStartDT; + } + + foreach ($lastShowDays as $dayOfWeek => $lastShowStartDT) { + $ccShowDay = CcShowDaysQuery::create() + ->filterByDbShowId($showId) + ->filterByDbDay($dayOfWeek) + ->filterByDbRepeatType(-1, Criteria::NOT_EQUAL) + ->findOne(); + + if (isset($ccShowDay)) { + $lastShowStartDT->setTimeZone(new DateTimeZone( + $ccShowDay->getDbTimezone())); + $lastShowEndDT = Application_Service_CalendarService::addDeltas( + $lastShowStartDT, 1, 0); + + $ccShowDay + ->setDbLastShow($lastShowEndDT->format("Y-m-d")) + ->save(); + } + } + + // NOTE: Some cc_show_day records may not get updated because there may not be an instance + // left on one of the repeating days so we have to find the entries where the last_show is + // still null + $showDays = CcShowDaysQuery::create() + ->filterByDbShowId($showId) + ->filterByDbRepeatType(0, Criteria::GREATER_EQUAL) + ->filterByDbLastShow(null) + ->find(); + foreach ($showDays as $showDay) { + $showDay->setDbLastShow($showDay->getDbFirstShow())->save(); } } @@ -739,50 +810,6 @@ SQL; if ($ccShowInstances->isEmpty()) { return true; } - /* We need to update the last_show in cc_show_days so the instances - * don't get recreated as the user moves forward in the calendar - */ - else if (count($ccShowInstances) >= 1) { - $lastShowDays = array(); - - //get the show's timezone - $ccShow = CcShowQuery::create()->findPk($showId); - if ($ccShow->isRepeating()) { - $showTimezone = $ccShow->getFirstRepeatingCcShowDay()->getDbTimezone(); - } else { - $showTimezone = $ccShow->getFirstCcShowDay()->getDbTimezone(); - } - - /* Creates an array where the key is the day of the week (monday, - * tuesday, etc.) and the value is the last show date for each - * day of the week. We will use this array to update the last_show - * for each cc_show_days entry of a cc_show - */ - foreach ($ccShowInstances as $instance) { - $instanceStartDT = $instance->getDbStarts(null); - $instanceStartDT->setTimezone(new DateTimeZone($showTimezone)); - $lastShowDays[$instanceStartDT->format("w")] = $instanceStartDT; - } - - foreach ($lastShowDays as $dayOfWeek => $lastShowStartDT) { - $ccShowDay = CcShowDaysQuery::create() - ->filterByDbShowId($showId) - ->filterByDbDay($dayOfWeek) - ->filterByDbRepeatType(-1, Criteria::NOT_EQUAL) - ->findOne(); - - if (isset($ccShowDay)) { - $lastShowStartDT->setTimeZone(new DateTimeZone( - $ccShowDay->getDbTimezone())); - $lastShowEndDT = Application_Service_CalendarService::addDeltas( - $lastShowStartDT, 1, 0); - - $ccShowDay - ->setDbLastShow($lastShowEndDT->format("Y-m-d")) - ->save(); - } - } - } return false; } From d5112f03688f2779442a3b8ce3da97557fc0e48a Mon Sep 17 00:00:00 2001 From: drigato Date: Mon, 20 Jan 2014 17:05:37 -0500 Subject: [PATCH 7/7] Added comments for a show_service function --- airtime_mvc/application/services/ShowService.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/airtime_mvc/application/services/ShowService.php b/airtime_mvc/application/services/ShowService.php index d8a7651a4..f71f9f8ca 100644 --- a/airtime_mvc/application/services/ShowService.php +++ b/airtime_mvc/application/services/ShowService.php @@ -1278,6 +1278,18 @@ SQL; return $dt; } + /** + * + * Returns a DateTime object of when the next repeating show that repeats + * monthly, by day of the week (i.e. every fourth Tuesday) should be created + * + * @param DateTime $start + * $start only has the year and month of the next show + * @param string $timezone + * @param string (i.e. '14:30' $startTime + * @param string (i.e. 'first', 'second') $weekNumberOfMonth + * @param string (i.e. 'Monday') $dayOfWeek + */ private function getNextMonthlyWeeklyRepeatDate( $start, $timezone,