CC-5589: SQL error when adding/moving a scheduled item
Error was occuring when a moved item didn't exist in a linked show instance Error was also occuring when trying to insert item into a schedule localtion that does not exist in a linked instance. Fixed by skipping the move action if the file does not exist in a linked instance, cleaning up the position numbers after deleting schedule items, and by setting the insert time to the show start time in a linked instance is empty
This commit is contained in:
parent
81912f2934
commit
eae93008b4
|
@ -626,19 +626,32 @@ class Application_Model_Scheduler
|
|||
$pos = Application_Common_Database::prepareAndExecute(
|
||||
$maxPos_sql, array(), Application_Common_Database::COLUMN);
|
||||
|
||||
$linkedItem_sql = "SELECT ends FROM cc_schedule ".
|
||||
"WHERE instance_id = {$instanceId} ".
|
||||
"AND position = {$pos} ".
|
||||
"AND playout_status != -1";
|
||||
$linkedItemEnds = Application_Common_Database::prepareAndExecute(
|
||||
$linkedItem_sql, array(), Application_Common_Database::COLUMN);
|
||||
//show instance has no scheduled tracks
|
||||
if (empty($pos)) {
|
||||
$pos = 0;
|
||||
$nextStartDT = new DateTime($instance["starts"], new DateTimeZone("UTC"));
|
||||
} else {
|
||||
|
||||
$linkedItem_sql = "SELECT ends FROM cc_schedule ".
|
||||
"WHERE instance_id = {$instanceId} ".
|
||||
"AND position = {$pos} ".
|
||||
"AND playout_status != -1";
|
||||
$linkedItemEnds = Application_Common_Database::prepareAndExecute(
|
||||
$linkedItem_sql, array(), Application_Common_Database::COLUMN);
|
||||
|
||||
$nextStartDT = $this->findNextStartTime(
|
||||
new DateTime($linkedItemEnds, new DateTimeZone("UTC")),
|
||||
$instanceId);
|
||||
}
|
||||
} else {
|
||||
$nextStartDT = $this->findNextStartTime(
|
||||
new DateTime($linkedItemEnds, new DateTimeZone("UTC")),
|
||||
$instanceId);
|
||||
|
||||
$pos++;
|
||||
}
|
||||
|
||||
$nextStartDT = $this->findNextStartTime(
|
||||
new DateTime($linkedItemEnds, new DateTimeZone("UTC")),
|
||||
$instanceId);
|
||||
|
||||
$pos++;
|
||||
//$pos++;
|
||||
}
|
||||
//selected empty row to add after
|
||||
else {
|
||||
|
@ -722,6 +735,13 @@ class Application_Model_Scheduler
|
|||
$sched = Application_Common_Database::prepareAndExecute(
|
||||
$movedItem_sql, array(), Application_Common_Database::SINGLE);
|
||||
}
|
||||
/* If we don't find a schedule item it means the linked
|
||||
* shows have a different amount of items (dyanmic block)
|
||||
* and we should skip the item move for this show instance
|
||||
*/
|
||||
if (!$sched) {
|
||||
continue;
|
||||
}
|
||||
$excludeIds[] = intval($sched["id"]);
|
||||
|
||||
$file["cliplength"] = $sched["clip_length"];
|
||||
|
@ -1160,6 +1180,7 @@ class Application_Model_Scheduler
|
|||
|
||||
foreach ($instances as $instance) {
|
||||
$instance->updateScheduleStatus($this->con);
|
||||
$instance->correctSchedulePositions();
|
||||
}
|
||||
|
||||
//update the last scheduled timestamp.
|
||||
|
|
|
@ -138,6 +138,29 @@ class CcShowInstances extends BaseCcShowInstances {
|
|||
$this->setDbLastScheduled(gmdate("Y-m-d H:i:s"));
|
||||
$this->save($con);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* This function resets the cc_schedule table's position numbers so that
|
||||
* tracks for each cc_show_instances start at position 1
|
||||
*
|
||||
* The position numbers can become out of sync when the user deletes items
|
||||
* from linekd shows filled with dyanmic smart blocks, where each instance
|
||||
* has a different amount of scheduled items
|
||||
*/
|
||||
public function correctSchedulePositions()
|
||||
{
|
||||
$schedule = CcScheduleQuery::create()
|
||||
->filterByDbInstanceId($this->id)
|
||||
->orderByDbStarts()
|
||||
->find();
|
||||
|
||||
$pos = 0;
|
||||
foreach ($schedule as $item) {
|
||||
$item->setDbPosition($pos)->save();
|
||||
$pos++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the value of the aggregate column time_filled
|
||||
|
|
Loading…
Reference in New Issue