CC-3542 : When you delete the current show it takes all songs from that show out of the playout history
This commit is contained in:
parent
9f0741a684
commit
eeb7273909
6 changed files with 210 additions and 91 deletions
|
@ -93,10 +93,10 @@ class Application_Model_Scheduler {
|
|||
throw new OutDatedScheduleException("The show {$show->getDbName()} is over and cannot be scheduled.");
|
||||
}
|
||||
|
||||
$origTs = intval($instanceInfo[$id]);
|
||||
$currTs = intval($instance->getDbLastScheduled("U")) ? : 0;
|
||||
if ($origTs !== $currTs) {
|
||||
Logging::log("orig {$origTs} current {$currTs}");
|
||||
$ts = intval($instanceInfo[$id]);
|
||||
$lastSchedTs = intval($instance->getDbLastScheduled("U")) ? : 0;
|
||||
if ($ts < $lastSchedTs) {
|
||||
Logging::log("ts {$ts} last sched {$lastSchedTs}");
|
||||
throw new OutDatedScheduleException("The show {$show->getDbName()} has been previously updated!");
|
||||
}
|
||||
}
|
||||
|
@ -215,6 +215,41 @@ class Application_Model_Scheduler {
|
|||
|
||||
return $nextDT;
|
||||
}
|
||||
|
||||
/*
|
||||
* @param int $showInstance
|
||||
* @param array $exclude
|
||||
* ids of sched items to remove from the calulation.
|
||||
*/
|
||||
private function removeGaps($showInstance, $exclude=null) {
|
||||
|
||||
Logging::log("removing gaps from show instance #".$showInstance);
|
||||
|
||||
$instance = CcShowInstancesQuery::create()->findPK($showInstance, $this->con);
|
||||
if (is_null($instance)) {
|
||||
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
|
||||
}
|
||||
|
||||
$itemStartDT = $instance->getDbStarts(null);
|
||||
|
||||
$schedule = CcScheduleQuery::create()
|
||||
->filterByDbInstanceId($showInstance)
|
||||
->filterByDbId($exclude, Criteria::NOT_IN)
|
||||
->orderByDbStarts()
|
||||
->find($this->con);
|
||||
|
||||
|
||||
foreach ($schedule as $item) {
|
||||
|
||||
$itemEndDT = $this->findEndTime($itemStartDT, $item->getDbClipLength());
|
||||
|
||||
$item->setDbStarts($itemStartDT)
|
||||
->setDbEnds($itemEndDT)
|
||||
->save($this->con);
|
||||
|
||||
$itemStartDT = $itemEndDT;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @param array $scheduledIds
|
||||
|
@ -280,16 +315,16 @@ class Application_Model_Scheduler {
|
|||
$sched = new CcSchedule();
|
||||
}
|
||||
|
||||
$sched->setDbStarts($nextStartDT);
|
||||
$sched->setDbEnds($endTimeDT);
|
||||
$sched->setDbFileId($file['id']);
|
||||
$sched->setDbCueIn($file['cuein']);
|
||||
$sched->setDbCueOut($file['cueout']);
|
||||
$sched->setDbFadeIn($file['fadein']);
|
||||
$sched->setDbFadeOut($file['fadeout']);
|
||||
$sched->setDbClipLength($file['cliplength']);
|
||||
$sched->setDbInstanceId($instance->getDbId());
|
||||
$sched->save($this->con);
|
||||
$sched->setDbStarts($nextStartDT)
|
||||
->setDbEnds($endTimeDT)
|
||||
->setDbFileId($file['id'])
|
||||
->setDbCueIn($file['cuein'])
|
||||
->setDbCueOut($file['cueout'])
|
||||
->setDbFadeIn($file['fadein'])
|
||||
->setDbFadeOut($file['fadeout'])
|
||||
->setDbClipLength($file['cliplength'])
|
||||
->setDbInstanceId($instance->getDbId())
|
||||
->save($this->con);
|
||||
|
||||
$nextStartDT = $endTimeDT;
|
||||
}
|
||||
|
@ -504,40 +539,45 @@ class Application_Model_Scheduler {
|
|||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @param int $showInstance
|
||||
* @param array $exclude
|
||||
* ids of sched items to remove from the calulation.
|
||||
* Used for cancelling the current show instance.
|
||||
*
|
||||
* @param $p_id id of the show instance to cancel.
|
||||
*/
|
||||
private function removeGaps($showInstance, $exclude=null) {
|
||||
|
||||
Logging::log("removing gaps from show instance #".$showInstance);
|
||||
|
||||
$instance = CcShowInstancesQuery::create()->findPK($showInstance, $this->con);
|
||||
if (is_null($instance)) {
|
||||
throw new OutDatedScheduleException("The schedule you're viewing is out of date!");
|
||||
}
|
||||
|
||||
$itemStartDT = $instance->getDbStarts(null);
|
||||
|
||||
$schedule = CcScheduleQuery::create()
|
||||
->filterByDbInstanceId($showInstance)
|
||||
->filterByDbId($exclude, Criteria::NOT_IN)
|
||||
->orderByDbStarts()
|
||||
->find($this->con);
|
||||
|
||||
|
||||
foreach ($schedule as $item) {
|
||||
|
||||
$itemEndDT = $this->findEndTime($itemStartDT, $item->getDbClipLength());
|
||||
|
||||
$item->setDbStarts($itemStartDT);
|
||||
$item->setDbEnds($itemEndDT);
|
||||
$item->save($this->con);
|
||||
|
||||
$itemStartDT = $itemEndDT;
|
||||
public function cancelShow($p_id) {
|
||||
|
||||
$this->con->beginTransaction();
|
||||
|
||||
try {
|
||||
|
||||
$instance = CcShowInstancesQuery::create()->findPK($p_id);
|
||||
|
||||
$items = CcScheduleQuery::create()
|
||||
->filterByDbInstanceId($p_id)
|
||||
->filterByDbEnds($this->nowDT, Criteria::GREATER_THAN)
|
||||
->find($this->con);
|
||||
|
||||
$remove = array();
|
||||
$ts = $this->nowDT->format('U');
|
||||
|
||||
for($i = 0; $i < count($items); $i++) {
|
||||
$remove[$i]["instance"] = $p_id;
|
||||
$remove[$i]["timestamp"] = $ts;
|
||||
$remove[$i]["id"] = $items[$i]->getDbId();
|
||||
}
|
||||
|
||||
$this->removeItems($remove, false);
|
||||
|
||||
$instance->setDbEnds($this->nowDT);
|
||||
$instance->save($this->con);
|
||||
|
||||
$this->con->commit();
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$this->con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ class Application_Model_ShowBuilder {
|
|||
private $pos;
|
||||
private $contentDT;
|
||||
private $epoch_now;
|
||||
private $currentShow;
|
||||
|
||||
private $defaultRowArray = array(
|
||||
"header" => false,
|
||||
|
@ -54,6 +55,7 @@ class Application_Model_ShowBuilder {
|
|||
$this->user = Application_Model_User::GetCurrentUser();
|
||||
$this->opts = $p_opts;
|
||||
$this->epoch_now = floatval(microtime(true));
|
||||
$this->currentShow = false;
|
||||
}
|
||||
|
||||
//check to see if this row should be editable by the user.
|
||||
|
@ -118,7 +120,7 @@ class Application_Model_ShowBuilder {
|
|||
else if ($row["footer"] === true && $this->epoch_now < $p_epochItemEnd) {
|
||||
$row["scheduled"] = 2;
|
||||
}
|
||||
else if ($row["header"] === true && $this->epoch_now > $p_epochItemStart) {
|
||||
else if ($row["header"] === true && $this->epoch_now >= $p_epochItemStart) {
|
||||
$row["scheduled"] = 0;
|
||||
}
|
||||
else if ($row["header"] === true && $this->epoch_now < $p_epochItemEnd) {
|
||||
|
@ -156,6 +158,14 @@ class Application_Model_ShowBuilder {
|
|||
$showEndDT = new DateTime($p_item["si_ends"], new DateTimeZone("UTC"));
|
||||
$showEndDT->setTimezone(new DateTimeZone($this->timezone));
|
||||
$endsEpoch = floatval($showEndDT->format("U.u"));
|
||||
|
||||
if ($startsEpoch < $this->epoch_now && $endsEpoch > $this->epoch_now) {
|
||||
$row["currentShow"] = true;
|
||||
$this->currentShow = true;
|
||||
}
|
||||
else {
|
||||
$this->currentShow = false;
|
||||
}
|
||||
|
||||
$row["header"] = true;
|
||||
$row["starts"] = $showStartDT->format("Y-m-d H:i");
|
||||
|
@ -224,6 +234,10 @@ class Application_Model_ShowBuilder {
|
|||
$row["id"] = 0 ;
|
||||
$row["instance"] = intval($p_item["si_id"]);
|
||||
}
|
||||
|
||||
if ($this->currentShow = true) {
|
||||
$row["currentShow"] = true;
|
||||
}
|
||||
|
||||
$this->getItemColor($p_item, $row);
|
||||
$this->getRowTimestamp($p_item, $row);
|
||||
|
@ -256,6 +270,10 @@ class Application_Model_ShowBuilder {
|
|||
$endsEpoch = floatval($showEndDT->format("U.u"));
|
||||
|
||||
$row["refresh"] = floatval($showEndDT->format("U.u")) - $this->epoch_now;
|
||||
|
||||
if ($this->currentShow = true) {
|
||||
$row["currentShow"] = true;
|
||||
}
|
||||
|
||||
$this->getScheduledStatus($startsEpoch, $endsEpoch, $row);
|
||||
$this->isAllowed($p_item, $row);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue