Skip to content

Commit

Permalink
cc-2344: wrong song displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
martin authored and martin committed Jun 3, 2011
1 parent c9c9ecf commit e69f949
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
14 changes: 7 additions & 7 deletions airtime_mvc/application/models/Dashboard.php
Expand Up @@ -10,8 +10,7 @@ public static function GetPreviousItem($p_timeNow){
//name. Else return the last item from the schedule.

$showInstance = ShowInstance::GetLastShowInstance($p_timeNow);
$instanceId = $showInstance->getShowId();
$row = Schedule::GetLastScheduleItem($p_timeNow, $instanceId);
$row = Schedule::GetLastScheduleItem($p_timeNow);

if (is_null($showInstance)){
if (count($row) == 0){
Expand Down Expand Up @@ -48,10 +47,12 @@ public static function GetCurrentItem($p_timeNow){
//after the last item in the schedule table, then return the show's
//name. Else return the last item from the schedule.

$row = array();
$showInstance = ShowInstance::GetCurrentShowInstance($p_timeNow);
$instanceId = $showInstance->getShowId();
$row = Schedule::GetCurrentScheduleItem($p_timeNow, $instanceId);

if (!is_null($showInstance)){
$instanceId = $showInstance->getShowInstanceId();
$row = Schedule::GetCurrentScheduleItem($p_timeNow, $instanceId);
}
if (is_null($showInstance)){
if (count($row) == 0){
return null;
Expand Down Expand Up @@ -84,8 +85,7 @@ public static function GetNextItem($p_timeNow){
//name. Else return the last item from the schedule.

$showInstance = ShowInstance::GetNextShowInstance($p_timeNow);
$instanceId = $showInstance->getShowId();
$row = Schedule::GetNextScheduleItem($p_timeNow, $instanceId);
$row = Schedule::GetNextScheduleItem($p_timeNow);

if (is_null($showInstance)){
if (count($row) == 0){
Expand Down
6 changes: 2 additions & 4 deletions airtime_mvc/application/models/Schedule.php
Expand Up @@ -378,15 +378,14 @@ public static function GetPlayOrderRange($prev = 1, $next = 1)
"apiKey"=>$CC_CONFIG['apiKey'][0]);
}

public static function GetLastScheduleItem($p_timeNow, $p_instanceId){
public static function GetLastScheduleItem($p_timeNow){
global $CC_CONFIG, $CC_DBC;

$sql = "SELECT *"
." FROM $CC_CONFIG[scheduleTable] st"
." LEFT JOIN $CC_CONFIG[filesTable] ft"
." ON st.file_id = ft.id"
." WHERE st.ends < TIMESTAMP '$p_timeNow'"
." AND st.instance_id = $p_instanceId"
." ORDER BY st.ends DESC"
." LIMIT 1";

Expand Down Expand Up @@ -419,15 +418,14 @@ public static function GetCurrentScheduleItem($p_timeNow, $p_instanceId){
return $row;
}

public static function GetNextScheduleItem($p_timeNow, $p_instanceId){
public static function GetNextScheduleItem($p_timeNow){
global $CC_CONFIG, $CC_DBC;

$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.instance_id = $p_instanceId"
." ORDER BY st.starts"
." LIMIT 1";

Expand Down

0 comments on commit e69f949

Please sign in to comment.