From 22218079af9c7d350c93f17ef382a4c1d1c8b4ac Mon Sep 17 00:00:00 2001 From: drigato Date: Fri, 15 Aug 2014 15:35:58 -0400 Subject: [PATCH] CC-5898: Future repeating shows may not get generated and/or filled with content Refactored show creation into separate function --- airtime_mvc/application/models/Schedule.php | 8 +------- airtime_mvc/application/models/Show.php | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index d8ae65bdf..dd7cd2065 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -974,13 +974,7 @@ SQL; $needScheduleUntil = new DateTime("now", new DateTimeZone("UTC")); $needScheduleUntil->add(new DateInterval("P1D")); } - $showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil(); - //if application is requesting shows past our previous populated until date, generate shows up until this point. - if (is_null($showsPopUntil) || $showsPopUntil->getTimestamp() < $needScheduleUntil->getTimestamp()) { - $service_show = new Application_Service_ShowService(); - $ccShow = $service_show->delegateInstanceCreation(null, $needScheduleUntil, true); - Application_Model_Preference::SetShowsPopulatedUntil($needScheduleUntil); - } + Application_Model_Show::createAndFillShowInstancesPastPopulatedUntilDate($needScheduleUntil); list($range_start, $range_end) = self::getRangeStartAndEnd($p_fromDateTime, $p_toDateTime); diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index e5daff311..cc1b572f0 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -830,6 +830,18 @@ SQL; } } + + public static function createAndFillShowInstancesPastPopulatedUntilDate($needScheduleUntil) + { + //UTC DateTime object + $showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil(); + //if application is requesting shows past our previous populated until date, generate shows up until this point. + if (is_null($showsPopUntil) || $showsPopUntil->getTimestamp() < $needScheduleUntil->getTimestamp()) { + $service_show = new Application_Service_ShowService(); + $ccShow = $service_show->delegateInstanceCreation(null, $needScheduleUntil, true); + Application_Model_Preference::SetShowsPopulatedUntil($needScheduleUntil); + } + } /** * Get all the show instances in the given time range (inclusive). @@ -844,14 +856,7 @@ SQL; */ public static function getShows($start_timestamp, $end_timestamp, $onlyRecord=FALSE) { - //UTC DateTime object - $showsPopUntil = Application_Model_Preference::GetShowsPopulatedUntil(); - //if application is requesting shows past our previous populated until date, generate shows up until this point. - if (is_null($showsPopUntil) || $showsPopUntil->getTimestamp() < $end_timestamp->getTimestamp()) { - $service_show = new Application_Service_ShowService(); - $ccShow = $service_show->delegateInstanceCreation(null, $end_timestamp, true); - Application_Model_Preference::SetShowsPopulatedUntil($end_timestamp); - } + self::createAndFillShowInstancesPastPopulatedUntilDate($end_timestamp); $sql = <<