From 164c158c806141e30b0686f81d0fc8d1053a8065 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 22 May 2012 17:39:27 -0400 Subject: [PATCH] CC-3859: Playout History: Filter out songs that are not played out - done --- airtime_mvc/application/models/LiveLog.php | 4 +++ .../application/models/PlayoutHistory.php | 2 +- airtime_mvc/application/models/Schedule.php | 26 +++++++++++++++++-- airtime_mvc/application/models/Show.php | 2 -- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/airtime_mvc/application/models/LiveLog.php b/airtime_mvc/application/models/LiveLog.php index 0f99c1b59..b641ef6ef 100644 --- a/airtime_mvc/application/models/LiveLog.php +++ b/airtime_mvc/application/models/LiveLog.php @@ -254,6 +254,10 @@ class Application_Model_LiveLog $sql_insert = "INSERT INTO CC_LIVE_LOG (state, start_time)" ." VALUES ('$state', '{$dateTime->format("Y-m-d H:i:s")}')"; $con->exec($sql_insert); + if($state == "S"){ + // if scheduled play source is getting broadcasted + Application_Model_Schedule::UpdateBrodcastedStatus($dateTime, 1); + } } } catch (Exception $e) { diff --git a/airtime_mvc/application/models/PlayoutHistory.php b/airtime_mvc/application/models/PlayoutHistory.php index 8e453f2ba..a5e4b9fb1 100644 --- a/airtime_mvc/application/models/PlayoutHistory.php +++ b/airtime_mvc/application/models/PlayoutHistory.php @@ -66,7 +66,7 @@ class Application_Model_PlayoutHistory { select count(schedule.file_id) as played, schedule.file_id as file_id from cc_schedule as schedule where schedule.starts >= '{$start}' and schedule.starts < '{$end}' - and schedule.playout_status > 0 and schedule.media_item_played != FALSE + and schedule.playout_status > 0 and schedule.media_item_played != FALSE and schedule.broadcasted = 1 group by schedule.file_id ) AS playout left join cc_files as file on (file.id = playout.file_id)"; diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index a1df73747..fc40b2801 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -293,8 +293,30 @@ class Application_Model_Schedule { global $CC_CONFIG; $con = Propel::getConnection(); $sql = "UPDATE ".$CC_CONFIG['scheduleTable'] - ." SET media_item_played=TRUE" - ." WHERE id=$p_id"; + ." SET media_item_played=TRUE"; + // we need to update 'broadcasted' column as well + // check the current switch status + $live_dj = Application_Model_Preference::GetSourceSwitchStatus('live_dj') == 'on'?true:false; + $master_dj = Application_Model_Preference::GetSourceSwitchStatus('master_dj') == 'on'?true:false; + $scheduled_play = Application_Model_Preference::GetSourceSwitchStatus('scheduled_play') == 'on'?true:false; + + if(!$live_dj && !$master_dj && $scheduled_play){ + $sql .= ", broadcasted=1"; + } + + $sql .= " WHERE id=$p_id"; + + $retVal = $con->exec($sql); + return $retVal; + } + + public static function UpdateBrodcastedStatus($dateTime, $value){ + global $CC_CONFIG; + $con = Propel::getConnection(); + $now = $dateTime->format("Y-m-d H:i:s"); + $sql = "UPDATE ".$CC_CONFIG['scheduleTable'] + ." SET broadcasted=$value" + ." WHERE starts <= '$now' AND ends >= '$now'"; $retVal = $con->exec($sql); return $retVal; } diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php index dc8c29026..cb91a454e 100644 --- a/airtime_mvc/application/models/Show.php +++ b/airtime_mvc/application/models/Show.php @@ -1519,8 +1519,6 @@ class Application_Model_Show { $sql = $sql." AND ({$exclude})"; } - Logging::debug("getShows"); - Logging::debug($sql); $result = $con->query($sql)->fetchAll(); return $result; }