From d03cf4ca14f08c6a6a964cd164d5c1824dbf3ff8 Mon Sep 17 00:00:00 2001 From: martin Date: Wed, 29 Jun 2011 14:40:56 -0400 Subject: [PATCH] CC-2482: Next Song/Previous song can still be incorrect in some rare cases -should be fixed. --- airtime_mvc/application/models/Schedule.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index 713ca2344..eb6226d84 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -383,11 +383,17 @@ class Schedule { public static function GetLastScheduleItem($p_timeNow){ global $CC_CONFIG, $CC_DBC; - $sql = "SELECT *" + $sql = "SELECT" + ." ft.artist_name, ft.track_title," + ." st.starts as starts, st.ends as ends" ." FROM $CC_CONFIG[scheduleTable] st" ." LEFT JOIN $CC_CONFIG[filesTable] ft" ." ON st.file_id = ft.id" + ." LEFT JOIN $CC_CONFIG[showInstances] sit" + ." ON st.instance_id = sit.id" ." WHERE st.ends < TIMESTAMP '$p_timeNow'" + ." AND st.starts >= sit.starts" //this and the next line are necessary since we can overbook shows. + ." AND st.starts < sit.ends" ." ORDER BY st.ends DESC" ." LIMIT 1"; @@ -423,11 +429,17 @@ class Schedule { public static function GetNextScheduleItem($p_timeNow){ global $CC_CONFIG, $CC_DBC; - $sql = "SELECT *" + $sql = "SELECT" + ." ft.artist_name, ft.track_title," + ." st.starts as starts, st.ends as ends" ." FROM $CC_CONFIG[scheduleTable] st" ." LEFT JOIN $CC_CONFIG[filesTable] ft" ." ON st.file_id = ft.id" + ." LEFT JOIN $CC_CONFIG[showInstances] sit" + ." ON st.instance_id = sit.id" ." WHERE st.starts > TIMESTAMP '$p_timeNow'" + ." AND st.starts >= sit.starts" //this and the next line are necessary since we can overbook shows. + ." AND st.starts < sit.ends" ." ORDER BY st.starts" ." LIMIT 1";