This commit is contained in:
mkonecny 2011-02-03 13:52:06 -05:00
parent 65cc694a90
commit a99a742bdc
3 changed files with 28 additions and 12 deletions

View File

@ -27,7 +27,7 @@ class Application_Model_Nowplaying
$arrayIndexOffset = 0; $arrayIndexOffset = 0;
if ($n < 2) if ($n < 2)
return; return $rows;
for ($i=1; $i<$n; $i++){ for ($i=1; $i<$n; $i++){
if ($rows[$i-1][3] != $rows[$i][2]) if ($rows[$i-1][3] != $rows[$i][2])

View File

@ -587,11 +587,15 @@ class Schedule {
public static function GetNextShow($timeNow) { public static function GetNextShow($timeNow) {
global $CC_CONFIG, $CC_DBC; global $CC_CONFIG, $CC_DBC;
$sql = "SELECT current_date + sd.start_time as start_timestamp, current_date + sd.end_time as end_timestamp, s.name, s.id" $datetime = explode(" ", $timeNow);
." FROM $CC_CONFIG[showDays] sd, $CC_CONFIG[showTable] s"
$sql = "SELECT *, (current_date + start_time) as start_timestamp, (current_date + end_time) as end_timestamp FROM "
." $CC_CONFIG[showDays] sd, $CC_CONFIG[showTable] s"
." WHERE sd.show_id = s.id" ." WHERE sd.show_id = s.id"
." AND (sd.first_show + sd.start_time) >= TIMESTAMP '$timeNow'" ." AND ((sd.last_show + sd.end_time) > TIMESTAMP '$timeNow' OR sd.last_show = NULL)"
." ORDER BY (sd.first_show + sd.start_time)" ." AND TIME '$datetime[1]' < sd.start_time "
." AND sd.day = EXTRACT(DOW FROM TIMESTAMP '$timeNow')"
." ORDER BY sd.start_time"
." LIMIT 1"; ." LIMIT 1";
$rows = $CC_DBC->GetAll($sql); $rows = $CC_DBC->GetAll($sql);

View File

@ -104,17 +104,23 @@ function updateProgressBarValue(){
//calculate how much time left to next song if there is any //calculate how much time left to next song if there is any
if (nextSongs.length > 0 && nextSongPrepare){ if (nextSongs.length > 0 && nextSongPrepare){
if (nextSongs[0].songStartPosixTime - estimatedSchedulePosixTime < serverUpdateInterval){ var diff = nextSongs[0].songStartPosixTime - estimatedSchedulePosixTime;
if (diff < serverUpdateInterval && diff >= 0){
nextSongPrepare = false; nextSongPrepare = false;
setTimeout(newSongStart, nextSongs[0].songStartPosixTime - estimatedSchedulePosixTime); setTimeout(newSongStart, diff);
} else if (diff < 0){
alert ("Warning: estimatedSchedulePosixTime > songStartPosixTime");
} }
} }
//calculate how much time left to next show if there is any //calculate how much time left to next show if there is any
if (nextShow.length > 0 && nextShowPrepare){ if (nextShow.length > 0 && nextShowPrepare){
if (nextShow[0].showStartPosixTime - estimatedSchedulePosixTime < serverUpdateInterval){ var diff = nextShow[0].showStartPosixTime - estimatedSchedulePosixTime;
if (diff < serverUpdateInterval && diff >= 0){
nextShowPrepare = false; nextShowPrepare = false;
setTimeout(nextShowStart, nextShow[0].showStartPosixTime - estimatedSchedulePosixTime); setTimeout(nextShowStart, diff);
} else if (diff < 0){
alert ("Warning: estimatedSchedulePosixTime > showStartPosixTime");
} }
} }
@ -185,6 +191,12 @@ function calcAdditionalShowData(show){
if (show.length > 0){ if (show.length > 0){
show[0].showStartPosixTime = convertDateToPosixTime(show[0].start_timestamp); show[0].showStartPosixTime = convertDateToPosixTime(show[0].start_timestamp);
show[0].showEndPosixTime = convertDateToPosixTime(show[0].end_timestamp); show[0].showEndPosixTime = convertDateToPosixTime(show[0].end_timestamp);
//hack to fix case where show end is next day, but we have it set
//as the same day.
if (show[0].showEndPosixTime - show[0].showStartPosixTime < 0)
show[0].showEndPosixTime += 1000*3600*24;
show[0].showLengthMs = show[0].showEndPosixTime - show[0].showStartPosixTime; show[0].showLengthMs = show[0].showEndPosixTime - show[0].showStartPosixTime;
} }
} }