From 520387fcad17f8631e929ca8928989b61d9ec8b6 Mon Sep 17 00:00:00 2001 From: drigato Date: Sat, 16 Aug 2014 11:05:55 -0400 Subject: [PATCH] CC-5898: Future repeating shows may not get generated and/or filled with content Create and fill show instances when pypo requests the schedule Changed getCcShowInstancess function to return all instances Changed some function calls to retrieve only show instances scheduled in the future --- airtime_mvc/application/models/Schedule.php | 15 +++++++++++++++ airtime_mvc/application/models/Scheduler.php | 2 +- airtime_mvc/application/models/airtime/CcShow.php | 1 - .../application/services/SchedulerService.php | 2 +- airtime_mvc/application/services/ShowService.php | 14 ++++++++++---- 5 files changed, 27 insertions(+), 7 deletions(-) diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index 7604e9939..d8ae65bdf 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -967,6 +967,21 @@ SQL; public static function getSchedule($p_fromDateTime = null, $p_toDateTime = null) { + //generate repeating shows if we are fetching the schedule + //for days beyond the shows_populated_until value in cc_pref + $needScheduleUntil = $p_toDateTime; + if (is_null($needScheduleUntil)) { + $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); + } + list($range_start, $range_end) = self::getRangeStartAndEnd($p_fromDateTime, $p_toDateTime); $data = array(); diff --git a/airtime_mvc/application/models/Scheduler.php b/airtime_mvc/application/models/Scheduler.php index 4aa1182c6..39415beaa 100644 --- a/airtime_mvc/application/models/Scheduler.php +++ b/airtime_mvc/application/models/Scheduler.php @@ -952,7 +952,7 @@ class Application_Model_Scheduler $ccShowInstance = CcShowInstancesQuery::create()->findPk($instanceId); $ccShow = $ccShowInstance->getCcShow(); if ($ccShow->isLinked()) { - return $ccShow->getCcShowInstancess(); + return $ccShow->getFutureCcShowInstancess(); } else { return array($ccShowInstance); } diff --git a/airtime_mvc/application/models/airtime/CcShow.php b/airtime_mvc/application/models/airtime/CcShow.php index 99d3649bc..7d4e55a6e 100644 --- a/airtime_mvc/application/models/airtime/CcShow.php +++ b/airtime_mvc/application/models/airtime/CcShow.php @@ -250,7 +250,6 @@ class CcShow extends BaseCcShow { return CcShowInstancesQuery::create(null, $criteria) ->filterByCcShow($this) ->filterByDbModifiedInstance(false) - ->filterByDbEnds(gmdate("Y-m-d H:i:s"), criteria::GREATER_THAN) ->orderByDbId() ->find($con); diff --git a/airtime_mvc/application/services/SchedulerService.php b/airtime_mvc/application/services/SchedulerService.php index 4b558cfc6..1b64e7aba 100644 --- a/airtime_mvc/application/services/SchedulerService.php +++ b/airtime_mvc/application/services/SchedulerService.php @@ -335,7 +335,7 @@ class Application_Service_SchedulerService $instanceIds = array(); if ($ccShowInstance->getCcShow()->isLinked()) { - foreach ($ccShowInstance->getCcShow()->getCcShowInstancess() as $instance) { + foreach ($ccShowInstance->getCcShow()->getFutureCcShowInstancess() as $instance) { $instanceIds[] = $instance->getDbId(); $instances[] = $instance; } diff --git a/airtime_mvc/application/services/ShowService.php b/airtime_mvc/application/services/ShowService.php index 3c6d5f713..f484ee670 100644 --- a/airtime_mvc/application/services/ShowService.php +++ b/airtime_mvc/application/services/ShowService.php @@ -256,19 +256,25 @@ class Application_Service_ShowService */ private function storeInstanceIds() { - $instances = $this->ccShow->getCcShowInstancess(); + $instances = $this->ccShow->getFutureCcShowInstancess(); foreach ($instances as $instance) { $this->instanceIdsForScheduleUpdates[] = $instance->getDbId(); } } + /** + * + * Adjusts the items in cc_schedule to reflect the + * new (if one) start and end time of the show getting updated + * @param $showData + */ private function adjustSchedule($showData) { $con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME); $this->updateScheduleStartEndTimes($showData); - $ccShowInstances = $this->ccShow->getCcShowInstancess(); + $ccShowInstances = $this->ccShow->getFutureCcShowInstancess(); foreach ($ccShowInstances as $instance) { $instance->updateScheduleStatus($con); } @@ -585,10 +591,10 @@ SQL; private function preserveLinkedShowContent() { - /* Get show content from any linked instance. It doesn't + /* Get show content from any future linked instance. It doesn't * matter which instance since content is the same in all. */ - $ccShowInstance = $this->ccShow->getCcShowInstancess()->getFirst(); + $ccShowInstance = $this->ccShow->getFutureCcShowInstancess()->getFirst(); if (!$ccShowInstance) { return;