From 951eeb0bbe9440f991ecedffc2bacd6d549644da Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 28 May 2013 11:07:45 -0400 Subject: [PATCH 1/2] CC-5178: Dashboard: Error happens after creating a show -fixed --- airtime_mvc/public/js/airtime/dashboard/dashboard.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/public/js/airtime/dashboard/dashboard.js b/airtime_mvc/public/js/airtime/dashboard/dashboard.js index 33bb89d46..0d9f0ae5b 100644 --- a/airtime_mvc/public/js/airtime/dashboard/dashboard.js +++ b/airtime_mvc/public/js/airtime/dashboard/dashboard.js @@ -262,14 +262,14 @@ function parseItems(obj){ if (obj.currentShow.length > 0) { calcAdditionalShowData(obj.currentShow); + currentShow = obj.currentShow; } if (obj.nextShow.length > 0) { calcAdditionalShowData(obj.nextShow); + nextShow = obj.nextShow; calculateTimeToNextShow(); } - currentShow = obj.currentShow; - nextShow = obj.nextShow; var schedulePosixTime = convertDateToPosixTime(obj.schedulerTime); var date = new Date(); From 85ee8aa0b26c35046ea57ee364507bf6c43f5b2a Mon Sep 17 00:00:00 2001 From: denise Date: Tue, 28 May 2013 11:25:37 -0400 Subject: [PATCH 2/2] Fixed bug where schedule start times were not getting calculated properly --- airtime_mvc/application/models/Scheduler.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/airtime_mvc/application/models/Scheduler.php b/airtime_mvc/application/models/Scheduler.php index 17410f6d6..4dc900cf8 100644 --- a/airtime_mvc/application/models/Scheduler.php +++ b/airtime_mvc/application/models/Scheduler.php @@ -592,6 +592,7 @@ class Application_Model_Scheduler $instance_sql); } + $excludePositions = array(); foreach($instances as &$instance) { $instanceId = $instance["id"]; if ($id !== 0) { @@ -618,9 +619,8 @@ class Application_Model_Scheduler $showStartDT = new DateTime($instance["starts"], new DateTimeZone("UTC")); $nextStartDT = $this->findNextStartTime($showStartDT, $instanceId); - //show is empty so start position counter at 0 + //first item in show so start position counter at 0 $pos = 0; - //$adjustSched = false; } if (!in_array($instanceId, $affectedShowInstances)) { @@ -753,12 +753,15 @@ class Application_Model_Scheduler $insert_sql = "INSERT INTO cc_schedule ". "(starts, ends, cue_in, cue_out, fade_in, fade_out, ". "clip_length, position, instance_id, file_id, stream_id) VALUES ". - implode($values, ","); + implode($values, ",")." RETURNING id"; - Application_Common_Database::prepareAndExecute( - $insert_sql, array(), Application_Common_Database::EXECUTE); + $stmt = $this->con->prepare($insert_sql); + if ($stmt->execute()) { + foreach ($stmt->fetchAll() as $row) { + $excludeIds[] = $row["id"]; + } + }; } - // update is_scheduled flag for each cc_file $fileIds = array(); foreach ($filesToInsert as &$file) { @@ -779,14 +782,14 @@ class Application_Model_Scheduler } if ($adjustSched === true) { + $followingItems_sql = "SELECT * FROM cc_schedule ". - "WHERE starts > '{$initalStartDT->format("Y-m-d H:i:s.u")}' ". + "WHERE starts >= '{$initalStartDT->format("Y-m-d H:i:s.u")}' ". "AND instance_id = {$instanceId} "; if (count($excludeIds) > 0) { $followingItems_sql .= "AND id NOT IN (". implode($excludeIds, ",").") "; } $followingItems_sql .= "ORDER BY starts"; - $followingSchedItems = Application_Common_Database::prepareAndExecute( $followingItems_sql);