CC-3504 : Adding a clip when nothing is playing should schedule the clip at the current time
This commit is contained in:
parent
7a6cdeaf10
commit
275faa1881
7 changed files with 83 additions and 28 deletions
|
@ -89,7 +89,7 @@ class Application_Model_Scheduler {
|
|||
*
|
||||
* @return DateTime endDT in UTC
|
||||
*/
|
||||
public static function findEndTime($p_startDT, $p_duration) {
|
||||
private static function findEndTime($p_startDT, $p_duration) {
|
||||
|
||||
$startEpoch = $p_startDT->format("U.u");
|
||||
$durationSeconds = Application_Model_Playlist::playlistTimeToSeconds($p_duration);
|
||||
|
@ -109,6 +109,39 @@ class Application_Model_Scheduler {
|
|||
|
||||
return $dt;
|
||||
}
|
||||
|
||||
private function findNextStartTime($DT, $instance) {
|
||||
|
||||
//check to see if the show has started.
|
||||
$nowDT = new DateTime("now", new DateTimeZone("UTC"));
|
||||
|
||||
$sEpoch = intval($DT->format("U"));
|
||||
$nEpoch = intval($nowDT->format("U"));
|
||||
|
||||
//check for if the show has started.
|
||||
if ($nEpoch > $sEpoch) {
|
||||
//need some kind of placeholder for cc_schedule.
|
||||
//playout_status will be -1.
|
||||
$nextDT = $nowDT;
|
||||
|
||||
$length = $nEpoch - $sEpoch;
|
||||
$cliplength = Application_Model_Playlist::secondsToPlaylistTime($length);
|
||||
|
||||
//fillers are for only storing a chunk of time space that has already passed.
|
||||
$filler = new CcSchedule();
|
||||
$filler->setDbStarts($DT)
|
||||
->setDbEnds($nowDT)
|
||||
->setDbClipLength($cliplength)
|
||||
->setDbPlayoutStatus(-1)
|
||||
->setDbInstanceId($instance->getDbId())
|
||||
->save($this->con);
|
||||
}
|
||||
else {
|
||||
$nextDT = $DT;
|
||||
}
|
||||
|
||||
return $nextDT;
|
||||
}
|
||||
|
||||
/*
|
||||
* @param array $scheduledIds
|
||||
|
@ -145,12 +178,16 @@ class Application_Model_Scheduler {
|
|||
if (intval($schedule["instance"]) !== $instance->getDbId()) {
|
||||
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
|
||||
}
|
||||
$nextStartDT = $schedItem->getDbEnds(null);
|
||||
$schedItemEndDT = $schedItem->getDbEnds(null);
|
||||
$nextStartDT = $this->findNextStartTime($schedItemEndDT, $instance);
|
||||
}
|
||||
//selected empty row to add after
|
||||
else {
|
||||
$instance = CcShowInstancesQuery::create()->findPK($schedule["instance"], $this->con);
|
||||
$nextStartDT = $instance->getDbStarts(null);
|
||||
|
||||
//check to see if the show has started.
|
||||
$showStartDT = $instance->getDbStarts(null);
|
||||
$nextStartDT = $this->findNextStartTime($showStartDT, $instance);
|
||||
}
|
||||
|
||||
$currTs = intval($instance->getDbLastScheduled("U")) ? : 0;
|
||||
|
@ -244,6 +281,7 @@ class Application_Model_Scheduler {
|
|||
->update(array('DbLastScheduled' => new DateTime("now", new DateTimeZone("UTC"))), $this->con);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
Logging::debug($e->getMessage());
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue