CC-5138: Linked Show: Time limitation exceeds when adding 24 hours smart block into daily repeating & linked shows

Made some small optimizations. Still needs more work.
This commit is contained in:
denise 2013-05-15 15:32:29 -04:00
parent f3edc2bee6
commit 491ea6a32c
1 changed files with 44 additions and 26 deletions

View File

@ -249,6 +249,8 @@ class Application_Model_Scheduler
$files[] = $data; $files[] = $data;
} }
} else { } else {
$defaultFadeIn = Application_Model_Preference::GetDefaultFadeIn();
$defaultFadeOut = Application_Model_Preference::GetDefaultFadeOut();
$dynamicFiles = $bl->getListOfFilesUnderLimit(); $dynamicFiles = $bl->getListOfFilesUnderLimit();
foreach ($dynamicFiles as $f) { foreach ($dynamicFiles as $f) {
$fileId = $f['id']; $fileId = $f['id'];
@ -263,8 +265,8 @@ class Application_Model_Scheduler
$data["cliplength"] = Application_Common_DateHelper::secondsToPlaylistTime($cueout - $cuein); $data["cliplength"] = Application_Common_DateHelper::secondsToPlaylistTime($cueout - $cuein);
//fade is in format SS.uuuuuu //fade is in format SS.uuuuuu
$data["fadein"] = Application_Model_Preference::GetDefaultFadeIn(); $data["fadein"] = $defaultFadeIn;
$data["fadeout"] = Application_Model_Preference::GetDefaultFadeOut(); $data["fadeout"] = $defaultFadeOut;
$data["type"] = 0; $data["type"] = 0;
$files[] = $data; $files[] = $data;
@ -306,6 +308,8 @@ class Application_Model_Scheduler
$files[] = $data; $files[] = $data;
} }
} else { } else {
$defaultFadeIn = Application_Model_Preference::GetDefaultFadeIn();
$defaultFadeOut = Application_Model_Preference::GetDefaultFadeOut();
$dynamicFiles = $bl->getListOfFilesUnderLimit(); $dynamicFiles = $bl->getListOfFilesUnderLimit();
foreach ($dynamicFiles as $f) { foreach ($dynamicFiles as $f) {
$fileId = $f['id']; $fileId = $f['id'];
@ -320,8 +324,8 @@ class Application_Model_Scheduler
$data["cliplength"] = Application_Common_DateHelper::secondsToPlaylistTime($cueout - $cuein); $data["cliplength"] = Application_Common_DateHelper::secondsToPlaylistTime($cueout - $cuein);
//fade is in format SS.uuuuuu //fade is in format SS.uuuuuu
$data["fadein"] = Application_Model_Preference::GetDefaultFadeIn(); $data["fadein"] = $defaultFadeIn;
$data["fadeout"] = Application_Model_Preference::GetDefaultFadeOut(); $data["fadeout"] = $defaultFadeOut;
$data["type"] = 0; $data["type"] = 0;
$files[] = $data; $files[] = $data;
@ -508,12 +512,15 @@ class Application_Model_Scheduler
$temp = array(); $temp = array();
$instance = null; $instance = null;
/* Items in shows are ordered by position number. We need to know /* Items in shows are ordered by position number. We need to know
* the position when adding/moving items in linked shows so they are * the position when adding/moving items in linked shows so they are
* added or moved in the correct position * added or moved in the correct position
*/ */
$pos = 0; $pos = 0;
$linked = false;
foreach ($scheduleItems as $schedule) { foreach ($scheduleItems as $schedule) {
$id = intval($schedule["id"]); $id = intval($schedule["id"]);
@ -524,10 +531,11 @@ class Application_Model_Scheduler
* of inserted items * of inserted items
*/ */
if ($id != 0) { if ($id != 0) {
$ccSchedule = CcScheduleQuery::create()->findPk($schedule["id"]); $ccSchedule = CcScheduleQuery::create()->findPk($id);
$ccShowInstance = CcShowInstancesQuery::create()->findPk($ccSchedule->getDbInstanceId()); $ccShowInstance = CcShowInstancesQuery::create()->findPk($ccSchedule->getDbInstanceId());
$ccShow = $ccShowInstance->getCcShow(); $ccShow = $ccShowInstance->getCcShow();
if ($ccShow->isLinked()) { $linked = $ccShow->isLinked();
if ($linked) {
$unique = $ccShow->getDbId() . $ccSchedule->getDbPosition(); $unique = $ccShow->getDbId() . $ccSchedule->getDbPosition();
if (!in_array($unique, $temp)) { if (!in_array($unique, $temp)) {
$temp[] = $unique; $temp[] = $unique;
@ -538,7 +546,8 @@ class Application_Model_Scheduler
} else { } else {
$ccShowInstance = CcShowInstancesQuery::create()->findPk($schedule["instance"]); $ccShowInstance = CcShowInstancesQuery::create()->findPk($schedule["instance"]);
$ccShow = $ccShowInstance->getccShow(); $ccShow = $ccShowInstance->getccShow();
if ($ccShow->isLinked()) { $linked = $ccShow->isLinked();
if ($linked) {
$unique = $ccShow->getDbId() . "a"; $unique = $ccShow->getDbId() . "a";
if (!in_array($unique, $temp)) { if (!in_array($unique, $temp)) {
$temp[] = $unique; $temp[] = $unique;
@ -552,23 +561,25 @@ class Application_Model_Scheduler
* we need to insert the items for each linked instance belonging * we need to insert the items for each linked instance belonging
* to that show * to that show
*/ */
$instances = $this->getInstances($schedule["instance"]); if ($linked) {
foreach($instances as $instance) { $instances = $ccShow->getCcShowInstancess();
$linked = $instance->getCcShow()->isLinked(); } else {
$instances = array($ccShowInstance);
}
foreach($instances as &$instance) {
$instanceId = $instance->getDbId();
if ($id !== 0) { if ($id !== 0) {
$schedItem = CcScheduleQuery::create()->findPK($id, $this->con);
/* We use the selected cursor's position to find the same /* We use the selected cursor's position to find the same
* positions in every other linked instance * positions in every other linked instance
*/ */
$pos = $schedItem->getDbPosition(); $pos = $ccSchedule->getDbPosition();
$ccSchedule = CcScheduleQuery::create() $linkCcSchedule = CcScheduleQuery::create()
->filterByDbInstanceId($instance->getDbId()) ->filterByDbInstanceId($instanceId)
->filterByDbPosition($pos) ->filterByDbPosition($pos)
->findOne(); ->findOne();
//$schedItemEndDT = $schedItem->getDbEnds(null); $schedItemEndDT = $linkCcSchedule->getDbEnds(null);
$schedItemEndDT = $ccSchedule->getDbEnds(null);
$nextStartDT = $this->findNextStartTime($schedItemEndDT, $instance); $nextStartDT = $this->findNextStartTime($schedItemEndDT, $instance);
$pos++; $pos++;
@ -583,7 +594,7 @@ class Application_Model_Scheduler
} }
if (!in_array($instance->getDbId(), $affectedShowInstances)) { if (!in_array($instance->getDbId(), $affectedShowInstances)) {
$affectedShowInstances[] = $instance->getDbId(); $affectedShowInstances[] = $instanceId;
} }
/* /*
@ -604,11 +615,12 @@ class Application_Model_Scheduler
if (is_null($filesToInsert)) { if (is_null($filesToInsert)) {
$filesToInsert = array(); $filesToInsert = array();
foreach ($mediaItems as $media) { foreach ($mediaItems as $media) {
$filesToInsert = array_merge($filesToInsert, $this->retrieveMediaFiles($media["id"], $media["type"])); $filesToInsert = array_merge($filesToInsert,
$this->retrieveMediaFiles($media["id"], $media["type"]));
} }
} }
foreach ($filesToInsert as $file) { foreach ($filesToInsert as &$file) {
//item existed previously and is being moved. //item existed previously and is being moved.
//need to keep same id for resources if we want REST. //need to keep same id for resources if we want REST.
if (isset($file['sched_id'])) { if (isset($file['sched_id'])) {
@ -628,7 +640,7 @@ class Application_Model_Scheduler
*/ */
if ($linked && $moveAction) { if ($linked && $moveAction) {
$sched = CcScheduleQuery::create() $sched = CcScheduleQuery::create()
->filterByDbInstanceId($instance->getDbId()) ->filterByDbInstanceId($instanceId)
->filterByDbPosition($originalPosition) ->filterByDbPosition($originalPosition)
->findOne(); ->findOne();
} }
@ -657,9 +669,9 @@ class Application_Model_Scheduler
->setDbFadeOut($file['fadeout']) ->setDbFadeOut($file['fadeout'])
->setDbClipLength($file['cliplength']) ->setDbClipLength($file['cliplength'])
->setDbPosition($pos); ->setDbPosition($pos);
//->setDbInstanceId($instance->getDbId());
if (!$moveAction) { if (!$moveAction) {
$sched->setDbInstanceId($instance->getDbId()); $sched->setDbInstanceId($instanceId);
} }
switch ($file["type"]) { switch ($file["type"]) {
@ -686,11 +698,17 @@ class Application_Model_Scheduler
}//all files have been inserted/moved }//all files have been inserted/moved
// update is_scheduled flag for each cc_file // update is_scheduled flag for each cc_file
foreach ($filesToInsert as $file) { $fileIds = array();
$db_file = CcFilesQuery::create()->findPk($file['id'], $this->con); foreach ($filesToInsert as &$file) {
$db_file->setDbIsScheduled(true); $fileIds[] = $file["id"];
$db_file->save($this->con);
} }
$selectCriteria = new Criteria();
$selectCriteria->add(CcFilesPeer::ID, $fileIds, Criteria::IN);
$selectCriteria->addAnd(CcFilesPeer::IS_SCHEDULED, false);
$updateCriteria = new Criteria();
$updateCriteria->add(CcFilesPeer::IS_SCHEDULED, true);
BasePeer::doUpdate($selectCriteria, $updateCriteria, $this->con);
/* Reset files to insert so we can get a new set of files. We have /* Reset files to insert so we can get a new set of files. We have
* to do this in case we are inserting a dynamic block * to do this in case we are inserting a dynamic block
*/ */