CC-3551 : Change Cue Out for currently deleted track
This commit is contained in:
parent
6135cbc79f
commit
cea37774ca
|
@ -772,10 +772,9 @@ class ScheduleController extends Zend_Controller_Action
|
|||
|
||||
public function cancelShowAction()
|
||||
{
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new Application_Model_User($userInfo->id);
|
||||
$user = Application_Model_User::GetCurrentUser();
|
||||
|
||||
if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
|
||||
if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
|
||||
$showInstanceId = $this->_getParam('id');
|
||||
|
||||
try {
|
||||
|
|
|
@ -254,9 +254,6 @@ class ShowbuilderController extends Zend_Controller_Action
|
|||
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
|
||||
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
|
||||
|
||||
Logging::log("showbuilder starts {$startsDT->format("Y-m-d H:i:s")}");
|
||||
Logging::log("showbuilder ends {$endsDT->format("Y-m-d H:i:s")}");
|
||||
|
||||
$opts = array("myShows" => $my_shows, "showFilter" => $show_filter);
|
||||
$showBuilder = new Application_Model_ShowBuilder($startsDT, $endsDT, $opts);
|
||||
|
||||
|
|
|
@ -75,13 +75,11 @@ class Application_Model_Datatables {
|
|||
}
|
||||
|
||||
try {
|
||||
$r = $con->query($sqlTotalRows);
|
||||
Logging::log($sqlTotalRows);
|
||||
$r = $con->query($sqlTotalRows);
|
||||
$totalRows = $r->fetchColumn(0);
|
||||
|
||||
if (isset($sqlTotalDisplayRows)) {
|
||||
$r = $con->query($sqlTotalDisplayRows);
|
||||
Logging::log($sqlTotalDisplayRows);
|
||||
$r = $con->query($sqlTotalDisplayRows);
|
||||
$totalDisplayRows = $r->fetchColumn(0);
|
||||
}
|
||||
else {
|
||||
|
@ -93,11 +91,11 @@ class Application_Model_Datatables {
|
|||
$results = $r->fetchAll();
|
||||
}
|
||||
catch (Exception $e) {
|
||||
Logging::log($e->getMessage());
|
||||
Logging::debug($e->getMessage());
|
||||
}
|
||||
|
||||
//display sql executed in airtime log for testing
|
||||
Logging::log($sql);
|
||||
//Logging::log($sql);
|
||||
|
||||
return array(
|
||||
"sEcho" => intval($data["sEcho"]),
|
||||
|
|
|
@ -261,8 +261,6 @@ class Application_Model_Schedule {
|
|||
|
||||
$sql .= " ORDER BY si.starts, sched.starts;";
|
||||
|
||||
Logging::log($sql);
|
||||
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
return $rows;
|
||||
}
|
||||
|
|
|
@ -13,13 +13,17 @@ class Application_Model_Scheduler {
|
|||
"sched_id" => null,
|
||||
);
|
||||
|
||||
private $epochNow;
|
||||
private $nowDT;
|
||||
private $user;
|
||||
|
||||
public function __construct($id = null) {
|
||||
|
||||
$this->con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
|
||||
$this->nowDT = new DateTime("now", new DateTimeZone("UTC"));
|
||||
|
||||
$this->epochNow = floatval(microtime(true));
|
||||
$this->nowDT = DateTime::createFromFormat("U.u", $this->epochNow, new DateTimeZone("UTC"));
|
||||
|
||||
$this->user = Application_Model_User::GetCurrentUser();
|
||||
}
|
||||
|
||||
|
@ -30,7 +34,7 @@ class Application_Model_Scheduler {
|
|||
*/
|
||||
private function validateRequest($items) {
|
||||
|
||||
$nowEpoch = intval($this->nowDT->format("U"));
|
||||
$nowEpoch = floatval($this->nowDT->format("U.u"));
|
||||
|
||||
for ($i = 0; $i < count($items); $i++) {
|
||||
$id = $items[$i]["id"];
|
||||
|
@ -83,7 +87,7 @@ class Application_Model_Scheduler {
|
|||
throw new Exception("You are not allowed to schedule show {$show->getDbName()}.");
|
||||
}
|
||||
|
||||
$showEndEpoch = intval($instance->getDbEnds("U"));
|
||||
$showEndEpoch = floatval($instance->getDbEnds("U.u"));
|
||||
|
||||
if ($showEndEpoch < $nowEpoch) {
|
||||
throw new OutDatedScheduleException("The show {$show->getDbName()} is over and cannot be scheduled.");
|
||||
|
@ -169,7 +173,7 @@ class Application_Model_Scheduler {
|
|||
*
|
||||
* @return DateTime endDT in UTC
|
||||
*/
|
||||
private static function findEndTime($p_startDT, $p_duration) {
|
||||
private function findEndTime($p_startDT, $p_duration) {
|
||||
|
||||
$startEpoch = $p_startDT->format("U.u");
|
||||
$durationSeconds = Application_Model_Playlist::playlistTimeToSeconds($p_duration);
|
||||
|
@ -178,22 +182,14 @@ class Application_Model_Scheduler {
|
|||
//DateTime::createFromFormat("U.u") will have a problem if there is no decimal in the resulting number.
|
||||
$endEpoch = bcadd($startEpoch , (string) $durationSeconds, 6);
|
||||
|
||||
Logging::log("start DateTime created {$p_startDT->format("Y-m-d H:i:s.u")}");
|
||||
Logging::log("start epoch is {$startEpoch}");
|
||||
Logging::log("duration in seconds is {$durationSeconds}");
|
||||
Logging::log("end epoch is {$endEpoch}");
|
||||
|
||||
$dt = DateTime::createFromFormat("U.u", $endEpoch, new DateTimeZone("UTC"));
|
||||
|
||||
Logging::log("end DateTime created {$dt->format("Y-m-d H:i:s.u")}");
|
||||
|
||||
return $dt;
|
||||
}
|
||||
|
||||
private function findNextStartTime($DT, $instance) {
|
||||
|
||||
$sEpoch = intval($DT->format("U"));
|
||||
$nowEpoch = intval($this->nowDT->format("U"));
|
||||
$sEpoch = floatval($DT->format("U.u"));
|
||||
$nowEpoch = $this->epochNow;
|
||||
|
||||
//check for if the show has started.
|
||||
if ($nowEpoch > $sEpoch) {
|
||||
|
@ -273,7 +269,7 @@ class Application_Model_Scheduler {
|
|||
|
||||
foreach($schedFiles as $file) {
|
||||
|
||||
$endTimeDT = self::findEndTime($nextStartDT, $file['cliplength']);
|
||||
$endTimeDT = $this->findEndTime($nextStartDT, $file['cliplength']);
|
||||
|
||||
//item existed previously and is being moved.
|
||||
//need to keep same id for resources if we want REST.
|
||||
|
@ -303,7 +299,7 @@ class Application_Model_Scheduler {
|
|||
//recalculate the start/end times after the inserted items.
|
||||
foreach ($followingSchedItems as $item) {
|
||||
|
||||
$endTimeDT = self::findEndTime($nextStartDT, $item->getDbClipLength());
|
||||
$endTimeDT = $this->findEndTime($nextStartDT, $item->getDbClipLength());
|
||||
|
||||
$item->setDbStarts($nextStartDT);
|
||||
$item->setDbEnds($endTimeDT);
|
||||
|
@ -448,17 +444,26 @@ class Application_Model_Scheduler {
|
|||
$instance = $removedItem->getCcShowInstances($this->con);
|
||||
|
||||
//check to truncate the currently playing item instead of deleting it.
|
||||
if ($removedItem->isCurrentItem()) {
|
||||
$now = new DateTime("now", new DateTimeZone("UTC"));
|
||||
if ($removedItem->isCurrentItem($this->epochNow)) {
|
||||
|
||||
$nEpoch = floatval($now->format('U.u'));
|
||||
$nEpoch = $this->epochNow;
|
||||
$sEpoch = floatval($removedItem->getDbStarts('U.u'));
|
||||
$length = $nEpoch - $sEpoch;
|
||||
$cliplength = Application_Model_Playlist::secondsToPlaylistTime($length);
|
||||
|
||||
$removedItem->setDbClipLength($cliplength);
|
||||
$removedItem->setDbEnds($now);
|
||||
$removedItem->save($this->con);
|
||||
$cueinSec = Application_Model_Playlist::playlistTimeToSeconds($removedItem->getDbCueIn());
|
||||
$cueOutSec = $cueinSec + $length;
|
||||
$cueout = Application_Model_Playlist::secondsToPlaylistTime($length);
|
||||
|
||||
Logging::log('$nEpoch: '. $nEpoch);
|
||||
Logging::log('$sEpoch: '. $sEpoch);
|
||||
Logging::log('$length: '. $length);
|
||||
Logging::log('$cliplength: '. $cliplength);
|
||||
|
||||
$removedItem->setDbCueOut($cueout)
|
||||
->setDbClipLength($cliplength)
|
||||
->setDbEnds($now)
|
||||
->save($this->con);
|
||||
}
|
||||
else {
|
||||
$removedItem->delete($this->con);
|
||||
|
@ -529,9 +534,7 @@ class Application_Model_Scheduler {
|
|||
|
||||
foreach ($schedule as $item) {
|
||||
|
||||
Logging::log("adjusting item #".$item->getDbId());
|
||||
|
||||
$itemEndDT = self::findEndTime($itemStartDT, $item->getDbClipLength());
|
||||
$itemEndDT = $this->findEndTime($itemStartDT, $item->getDbClipLength());
|
||||
|
||||
$item->setDbStarts($itemStartDT);
|
||||
$item->setDbEnds($itemEndDT);
|
||||
|
|
|
@ -224,11 +224,14 @@ class CcSchedule extends BaseCcSchedule {
|
|||
return $this;
|
||||
} // setDbEnds()
|
||||
|
||||
public function isCurrentItem() {
|
||||
public function isCurrentItem($epochNow = null) {
|
||||
|
||||
$epochNow = time();
|
||||
$epochStart = intval($this->getDbStarts('U'));
|
||||
$epochEnd = intval($this->getDbEnds('U'));
|
||||
if (is_null($epochNow)) {
|
||||
$epochNow = microtime(true);
|
||||
}
|
||||
|
||||
$epochStart = floatval($this->getDbStarts('U.u'));
|
||||
$epochEnd = floatval($this->getDbEnds('U.u'));
|
||||
|
||||
if ($epochStart < $epochNow && $epochEnd > $epochNow) {
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue