From 9e9ae1172556133b75c150273ad4e96554e75d8f Mon Sep 17 00:00:00 2001 From: Naomi Aro Date: Fri, 30 Mar 2012 12:24:55 +0200 Subject: [PATCH] CC-3551 : Change Cue Out for currently deleted track --- airtime_mvc/application/models/Schedule.php | 2 ++ airtime_mvc/application/models/Scheduler.php | 25 ++++++++++---------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index 4277bb9d6..b474b1c8e 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -416,6 +416,7 @@ class Application_Model_Schedule { $predicates = " WHERE st.ends > '$p_startTime'" ." AND st.starts < '$p_endTime'" + ." AND st.playout_status > 0" ." ORDER BY st.starts"; $sql = $baseQuery.$predicates; @@ -434,6 +435,7 @@ class Application_Model_Schedule { $predicates = " WHERE st.ends > '$p_startTime'" ." AND st.starts < '$range_end'" + ." AND st.playout_status > 0" ." ORDER BY st.starts" ." LIMIT 3"; diff --git a/airtime_mvc/application/models/Scheduler.php b/airtime_mvc/application/models/Scheduler.php index 30c72c2d2..647461ae9 100644 --- a/airtime_mvc/application/models/Scheduler.php +++ b/airtime_mvc/application/models/Scheduler.php @@ -21,7 +21,7 @@ class Application_Model_Scheduler { $this->con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME); - $this->epochNow = floatval(microtime(true)); + $this->epochNow = microtime(true); $this->nowDT = DateTime::createFromFormat("U.u", $this->epochNow, new DateTimeZone("UTC")); $this->user = Application_Model_User::GetCurrentUser(); @@ -188,16 +188,16 @@ class Application_Model_Scheduler { private function findNextStartTime($DT, $instance) { - $sEpoch = floatval($DT->format("U.u")); - $nowEpoch = $this->epochNow; + $sEpoch = $DT->format("U.u"); + $nEpoch = $this->epochNow; //check for if the show has started. - if ($nowEpoch > $sEpoch) { + if (bccomp( $nEpoch , $sEpoch , 6) === 1) { //need some kind of placeholder for cc_schedule. //playout_status will be -1. - $nextDT = $this->nowDT; - - $length = $nowEpoch - $sEpoch; + $nextDT = $this->nowDT; + + $length = bcsub($nEpoch , $sEpoch , 6); $cliplength = Application_Model_Playlist::secondsToPlaylistTime($length); //fillers are for only storing a chunk of time space that has already passed. @@ -447,13 +447,14 @@ class Application_Model_Scheduler { if ($removedItem->isCurrentItem($this->epochNow)) { $nEpoch = $this->epochNow; - $sEpoch = floatval($removedItem->getDbStarts('U.u')); - $length = $nEpoch - $sEpoch; + $sEpoch = $removedItem->getDbStarts('U.u'); + + $length = bcsub($nEpoch , $sEpoch , 6); $cliplength = Application_Model_Playlist::secondsToPlaylistTime($length); $cueinSec = Application_Model_Playlist::playlistTimeToSeconds($removedItem->getDbCueIn()); - $cueOutSec = $cueinSec + $length; - $cueout = Application_Model_Playlist::secondsToPlaylistTime($length); + $cueOutSec = bcadd($cueinSec , $length, 6); + $cueout = Application_Model_Playlist::secondsToPlaylistTime($cueOutSec); Logging::log('$nEpoch: '. $nEpoch); Logging::log('$sEpoch: '. $sEpoch); @@ -462,7 +463,7 @@ class Application_Model_Scheduler { $removedItem->setDbCueOut($cueout) ->setDbClipLength($cliplength) - ->setDbEnds($now) + ->setDbEnds($this->nowDT) ->save($this->con); } else {