cc-2344: wrong song displayed
-fixed
This commit is contained in:
parent
19e52e81b5
commit
c9c9ecf2cd
2 changed files with 25 additions and 10 deletions
|
@ -10,14 +10,16 @@ class Application_Model_Dashboard
|
||||||
//name. Else return the last item from the schedule.
|
//name. Else return the last item from the schedule.
|
||||||
|
|
||||||
$showInstance = ShowInstance::GetLastShowInstance($p_timeNow);
|
$showInstance = ShowInstance::GetLastShowInstance($p_timeNow);
|
||||||
$row = Schedule::GetLastScheduleItem($p_timeNow);
|
$instanceId = $showInstance->getShowId();
|
||||||
|
$row = Schedule::GetLastScheduleItem($p_timeNow, $instanceId);
|
||||||
|
|
||||||
if (is_null($showInstance)){
|
if (is_null($showInstance)){
|
||||||
if (count($row) == 0){
|
if (count($row) == 0){
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
//should never reach here. Doesnt make sense to have
|
return array("name"=>$row[0]["artist_name"]." - ".$row[0]["track_title"],
|
||||||
//a schedule item not within a show_instance.
|
"starts"=>$row[0]["starts"],
|
||||||
|
"ends"=>$row[0]["ends"]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (count($row) == 0){
|
if (count($row) == 0){
|
||||||
|
@ -47,7 +49,8 @@ class Application_Model_Dashboard
|
||||||
//name. Else return the last item from the schedule.
|
//name. Else return the last item from the schedule.
|
||||||
|
|
||||||
$showInstance = ShowInstance::GetCurrentShowInstance($p_timeNow);
|
$showInstance = ShowInstance::GetCurrentShowInstance($p_timeNow);
|
||||||
$row = Schedule::GetCurrentScheduleItem($p_timeNow);
|
$instanceId = $showInstance->getShowId();
|
||||||
|
$row = Schedule::GetCurrentScheduleItem($p_timeNow, $instanceId);
|
||||||
|
|
||||||
if (is_null($showInstance)){
|
if (is_null($showInstance)){
|
||||||
if (count($row) == 0){
|
if (count($row) == 0){
|
||||||
|
@ -62,8 +65,8 @@ class Application_Model_Dashboard
|
||||||
return array("name"=>$showInstance->getName(),
|
return array("name"=>$showInstance->getName(),
|
||||||
"starts"=>$showInstance->getShowStart(),
|
"starts"=>$showInstance->getShowStart(),
|
||||||
"ends"=>$showInstance->getShowEnd(),
|
"ends"=>$showInstance->getShowEnd(),
|
||||||
"media_item_played"=>false, //TODO
|
"media_item_played"=>false,
|
||||||
"record"=>$showInstance->isRecorded()); //TODO
|
"record"=>$showInstance->isRecorded());
|
||||||
} else {
|
} else {
|
||||||
return array("name"=>$row[0]["artist_name"]." - ".$row[0]["track_title"],
|
return array("name"=>$row[0]["artist_name"]." - ".$row[0]["track_title"],
|
||||||
"starts"=>$row[0]["starts"],
|
"starts"=>$row[0]["starts"],
|
||||||
|
@ -81,7 +84,8 @@ class Application_Model_Dashboard
|
||||||
//name. Else return the last item from the schedule.
|
//name. Else return the last item from the schedule.
|
||||||
|
|
||||||
$showInstance = ShowInstance::GetNextShowInstance($p_timeNow);
|
$showInstance = ShowInstance::GetNextShowInstance($p_timeNow);
|
||||||
$row = Schedule::GetNextScheduleItem($p_timeNow);
|
$instanceId = $showInstance->getShowId();
|
||||||
|
$row = Schedule::GetNextScheduleItem($p_timeNow, $instanceId);
|
||||||
|
|
||||||
if (is_null($showInstance)){
|
if (is_null($showInstance)){
|
||||||
if (count($row) == 0){
|
if (count($row) == 0){
|
||||||
|
|
|
@ -378,7 +378,7 @@ class Schedule {
|
||||||
"apiKey"=>$CC_CONFIG['apiKey'][0]);
|
"apiKey"=>$CC_CONFIG['apiKey'][0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetLastScheduleItem($p_timeNow){
|
public static function GetLastScheduleItem($p_timeNow, $p_instanceId){
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
|
||||||
$sql = "SELECT *"
|
$sql = "SELECT *"
|
||||||
|
@ -386,6 +386,7 @@ class Schedule {
|
||||||
." LEFT JOIN $CC_CONFIG[filesTable] ft"
|
." LEFT JOIN $CC_CONFIG[filesTable] ft"
|
||||||
." ON st.file_id = ft.id"
|
." ON st.file_id = ft.id"
|
||||||
." WHERE st.ends < TIMESTAMP '$p_timeNow'"
|
." WHERE st.ends < TIMESTAMP '$p_timeNow'"
|
||||||
|
." AND st.instance_id = $p_instanceId"
|
||||||
." ORDER BY st.ends DESC"
|
." ORDER BY st.ends DESC"
|
||||||
." LIMIT 1";
|
." LIMIT 1";
|
||||||
|
|
||||||
|
@ -394,22 +395,31 @@ class Schedule {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function GetCurrentScheduleItem($p_timeNow){
|
public static function GetCurrentScheduleItem($p_timeNow, $p_instanceId){
|
||||||
global $CC_CONFIG, $CC_DBC;
|
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 *"
|
$sql = "SELECT *"
|
||||||
." FROM $CC_CONFIG[scheduleTable] st"
|
." FROM $CC_CONFIG[scheduleTable] st"
|
||||||
." LEFT JOIN $CC_CONFIG[filesTable] ft"
|
." LEFT JOIN $CC_CONFIG[filesTable] ft"
|
||||||
." ON st.file_id = ft.id"
|
." ON st.file_id = ft.id"
|
||||||
." WHERE st.starts <= TIMESTAMP '$p_timeNow'"
|
." WHERE st.starts <= TIMESTAMP '$p_timeNow'"
|
||||||
|
." AND st.instance_id = $p_instanceId"
|
||||||
." AND st.ends > TIMESTAMP '$p_timeNow'"
|
." AND st.ends > TIMESTAMP '$p_timeNow'"
|
||||||
|
." ORDER BY st.starts DESC"
|
||||||
." LIMIT 1";
|
." LIMIT 1";
|
||||||
|
|
||||||
$row = $CC_DBC->GetAll($sql);
|
$row = $CC_DBC->GetAll($sql);
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function GetNextScheduleItem($p_timeNow){
|
public static function GetNextScheduleItem($p_timeNow, $p_instanceId){
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
|
||||||
$sql = "SELECT *"
|
$sql = "SELECT *"
|
||||||
|
@ -417,6 +427,7 @@ class Schedule {
|
||||||
." LEFT JOIN $CC_CONFIG[filesTable] ft"
|
." LEFT JOIN $CC_CONFIG[filesTable] ft"
|
||||||
." ON st.file_id = ft.id"
|
." ON st.file_id = ft.id"
|
||||||
." WHERE st.starts > TIMESTAMP '$p_timeNow'"
|
." WHERE st.starts > TIMESTAMP '$p_timeNow'"
|
||||||
|
." AND st.instance_id = $p_instanceId"
|
||||||
." ORDER BY st.starts"
|
." ORDER BY st.starts"
|
||||||
." LIMIT 1";
|
." LIMIT 1";
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue