From b747ce6fb0addd886887c8b0b4b28e81279ee40c Mon Sep 17 00:00:00 2001 From: martin Date: Thu, 2 Jun 2011 12:45:57 -0400 Subject: [PATCH] cc-2344: wrong song displayed -fixed --- airtime_mvc/application/models/Dashboard.php | 18 ++++++++++++------ airtime_mvc/application/models/Schedule.php | 8 ++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/airtime_mvc/application/models/Dashboard.php b/airtime_mvc/application/models/Dashboard.php index f7d5113b2..37b439570 100644 --- a/airtime_mvc/application/models/Dashboard.php +++ b/airtime_mvc/application/models/Dashboard.php @@ -16,8 +16,9 @@ class Application_Model_Dashboard if (count($row) == 0){ return null; } else { - //should never reach here. Doesnt make sense to have - //a schedule item not within a show_instance. + return array("name"=>$row[0]["artist_name"]." - ".$row[0]["track_title"], + "starts"=>$row[0]["starts"], + "ends"=>$row[0]["ends"]); } } else { if (count($row) == 0){ @@ -53,8 +54,13 @@ class Application_Model_Dashboard if (count($row) == 0){ return null; } else { - //should never reach here. Doesnt make sense to have - //a schedule item not within a show_instance. + /* Should never reach here, but lets return the track information + * just in case we allow tracks to be scheduled without a show + * in the future. + */ + return array("name"=>$row[0]["artist_name"]." - ".$row[0]["track_title"], + "starts"=>$row[0]["starts"], + "ends"=>$row[0]["ends"]); } } else { if (count($row) == 0){ @@ -62,8 +68,8 @@ class Application_Model_Dashboard return array("name"=>$showInstance->getName(), "starts"=>$showInstance->getShowStart(), "ends"=>$showInstance->getShowEnd(), - "media_item_played"=>false, //TODO - "record"=>$showInstance->isRecorded()); //TODO + "media_item_played"=>false, + "record"=>$showInstance->isRecorded()); } else { return array("name"=>$row[0]["artist_name"]." - ".$row[0]["track_title"], "starts"=>$row[0]["starts"], diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index d6a647d8e..0e6b57a78 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -397,12 +397,20 @@ class Schedule { public static function GetCurrentScheduleItem($p_timeNow){ global $CC_CONFIG, $CC_DBC; + /* Note that usually there will be one result returned. In some + * rare cases two songs are returned. This happens when a track + * that was overbooked from a previous show appears as if it + * hasnt ended yet (track end time hasn't been reached yet). For + * this reason, we need to get the track that starts later, as + * this is the *real* track that is currently playing. So this + * is why we are ordering by track start time. */ $sql = "SELECT *" ." FROM $CC_CONFIG[scheduleTable] st" ." LEFT JOIN $CC_CONFIG[filesTable] ft" ." ON st.file_id = ft.id" ." WHERE st.starts <= TIMESTAMP '$p_timeNow'" ." AND st.ends > TIMESTAMP '$p_timeNow'" + ." ORDER BY st.starts DESC" ." LIMIT 1"; $row = $CC_DBC->GetAll($sql);