CC-3285 : Nowplaying
nowplaying didn't show correct start date if show crossed 0:00 boundry.
This commit is contained in:
parent
252777c3f9
commit
d257ddf482
|
@ -9,47 +9,47 @@ class Application_Model_Nowplaying
|
||||||
|
|
||||||
private static function CreateDatatableRows($p_dbRows){
|
private static function CreateDatatableRows($p_dbRows){
|
||||||
$dataTablesRows = array();
|
$dataTablesRows = array();
|
||||||
|
|
||||||
$epochNow = time();
|
$epochNow = time();
|
||||||
|
|
||||||
foreach ($p_dbRows as $dbRow){
|
foreach ($p_dbRows as $dbRow){
|
||||||
|
|
||||||
$showStartDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['show_starts']);
|
$showStartDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['show_starts']);
|
||||||
$showEndDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['show_ends']);
|
$showEndDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['show_ends']);
|
||||||
$itemStartDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['item_starts']);
|
$itemStartDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['item_starts']);
|
||||||
$itemEndDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['item_ends']);
|
$itemEndDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['item_ends']);
|
||||||
|
|
||||||
$showStarts = $showStartDateTime->format("Y-m-d H:i:s");
|
$showStarts = $showStartDateTime->format("Y-m-d H:i:s");
|
||||||
$showEnds = $showEndDateTime->format("Y-m-d H:i:s");
|
$showEnds = $showEndDateTime->format("Y-m-d H:i:s");
|
||||||
$itemStarts = $itemStartDateTime->format("Y-m-d H:i:s");
|
$itemStarts = $itemStartDateTime->format("Y-m-d H:i:s");
|
||||||
$itemEnds = $itemEndDateTime->format("Y-m-d H:i:s");
|
$itemEnds = $itemEndDateTime->format("Y-m-d H:i:s");
|
||||||
|
|
||||||
$status = ($dbRow['show_ends'] < $dbRow['item_ends']) ? "x" : "";
|
$status = ($dbRow['show_ends'] < $dbRow['item_ends']) ? "x" : "";
|
||||||
|
|
||||||
$type = "a";
|
$type = "a";
|
||||||
$type .= ($itemStartDateTime->getTimestamp() <= $epochNow
|
$type .= ($itemStartDateTime->getTimestamp() <= $epochNow
|
||||||
&& $epochNow < $itemEndDateTime->getTimestamp()
|
&& $epochNow < $itemEndDateTime->getTimestamp()
|
||||||
&& $epochNow < $showEndDateTime->getTimestamp()) ? "c" : "";
|
&& $epochNow < $showEndDateTime->getTimestamp()) ? "c" : "";
|
||||||
|
|
||||||
// remove millisecond from the time format
|
// remove millisecond from the time format
|
||||||
$itemStart = explode('.', $dbRow['item_starts']);
|
$itemStart = explode('.', $dbRow['item_starts']);
|
||||||
$itemEnd = explode('.', $dbRow['item_ends']);
|
$itemEnd = explode('.', $dbRow['item_ends']);
|
||||||
|
|
||||||
//format duration
|
//format duration
|
||||||
$duration = explode('.', $dbRow['clip_length']);
|
$duration = explode('.', $dbRow['clip_length']);
|
||||||
$formatted = self::FormatDuration($duration[0]);
|
$formatted = self::FormatDuration($duration[0]);
|
||||||
$dataTablesRows[] = array($type, $showStarts, $itemStarts, $itemEnds,
|
$dataTablesRows[] = array($type, $itemStarts, $itemStarts, $itemEnds,
|
||||||
$formatted, $dbRow['track_title'], $dbRow['artist_name'], $dbRow['album_title'],
|
$formatted, $dbRow['track_title'], $dbRow['artist_name'], $dbRow['album_title'],
|
||||||
$dbRow['playlist_name'], $dbRow['show_name'], $status);
|
$dbRow['playlist_name'], $dbRow['show_name'], $status);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $dataTablesRows;
|
return $dataTablesRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function CreateGapRow($p_gapTime){
|
private static function CreateGapRow($p_gapTime){
|
||||||
return array("g", "", "", "", $p_gapTime, "", "", "", "", "", "");
|
return array("g", "", "", "", $p_gapTime, "", "", "", "", "", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function CreateRecordingRow($p_showInstance){
|
private static function CreateRecordingRow($p_showInstance){
|
||||||
return array("r", "", "", "", $p_showInstance->getName(), "", "", "", "", "", "");
|
return array("r", "", "", "", $p_showInstance->getName(), "", "", "", "", "", "");
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ class Application_Model_Nowplaying
|
||||||
if ($viewType == "now"){
|
if ($viewType == "now"){
|
||||||
$dateTime = new DateTime("now", new DateTimeZone("UTC"));
|
$dateTime = new DateTime("now", new DateTimeZone("UTC"));
|
||||||
$timeNow = $dateTime->format("Y-m-d H:i:s");
|
$timeNow = $dateTime->format("Y-m-d H:i:s");
|
||||||
|
|
||||||
$startCutoff = 60;
|
$startCutoff = 60;
|
||||||
$endCutoff = 86400; //60*60*24 - seconds in a day
|
$endCutoff = 86400; //60*60*24 - seconds in a day
|
||||||
} else {
|
} else {
|
||||||
|
@ -71,30 +71,30 @@ class Application_Model_Nowplaying
|
||||||
$startCutoff = $date->getNowDayStartDiff();
|
$startCutoff = $date->getNowDayStartDiff();
|
||||||
$endCutoff = $date->getNowDayEndDiff();
|
$endCutoff = $date->getNowDayEndDiff();
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
|
|
||||||
$showIds = Application_Model_ShowInstance::GetShowsInstancesIdsInRange($timeNow, $startCutoff, $endCutoff);
|
$showIds = Application_Model_ShowInstance::GetShowsInstancesIdsInRange($timeNow, $startCutoff, $endCutoff);
|
||||||
foreach ($showIds as $showId){
|
foreach ($showIds as $showId){
|
||||||
$instanceId = $showId['id'];
|
$instanceId = $showId['id'];
|
||||||
|
|
||||||
$si = new Application_Model_ShowInstance($instanceId);
|
$si = new Application_Model_ShowInstance($instanceId);
|
||||||
|
|
||||||
$showId = $si->getShowId();
|
$showId = $si->getShowId();
|
||||||
$show = new Application_Model_Show($showId);
|
$show = new Application_Model_Show($showId);
|
||||||
|
|
||||||
$showStartDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($si->getShowInstanceStart());
|
$showStartDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($si->getShowInstanceStart());
|
||||||
$showEndDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($si->getShowInstanceEnd());
|
$showEndDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($si->getShowInstanceEnd());
|
||||||
|
|
||||||
//append show header row
|
//append show header row
|
||||||
$data[] = self::CreateHeaderRow($show->getName(), $showStartDateTime->format("Y-m-d H:i:s"), $showEndDateTime->format("Y-m-d H:i:s"));
|
$data[] = self::CreateHeaderRow($show->getName(), $showStartDateTime->format("Y-m-d H:i:s"), $showEndDateTime->format("Y-m-d H:i:s"));
|
||||||
|
|
||||||
$scheduledItems = $si->getScheduleItemsInRange($timeNow, $startCutoff, $endCutoff);
|
$scheduledItems = $si->getScheduleItemsInRange($timeNow, $startCutoff, $endCutoff);
|
||||||
$dataTablesRows = self::CreateDatatableRows($scheduledItems);
|
$dataTablesRows = self::CreateDatatableRows($scheduledItems);
|
||||||
|
|
||||||
//append show audio item rows
|
//append show audio item rows
|
||||||
$data = array_merge($data, $dataTablesRows);
|
$data = array_merge($data, $dataTablesRows);
|
||||||
|
|
||||||
//append show gap time row
|
//append show gap time row
|
||||||
$gapTime = self::FormatDuration($si->getShowEndGapTime(), true);
|
$gapTime = self::FormatDuration($si->getShowEndGapTime(), true);
|
||||||
if ($si->isRecorded())
|
if ($si->isRecorded())
|
||||||
|
@ -117,7 +117,7 @@ class Application_Model_Nowplaying
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* default $time format should be in format of 00:00:00
|
* default $time format should be in format of 00:00:00
|
||||||
* if $inSecond = true, then $time should be in seconds
|
* if $inSecond = true, then $time should be in seconds
|
||||||
*/
|
*/
|
||||||
private static function FormatDuration($time, $inSecond=false){
|
private static function FormatDuration($time, $inSecond=false){
|
||||||
if($inSecond == false){
|
if($inSecond == false){
|
||||||
|
@ -128,13 +128,13 @@ class Application_Model_Nowplaying
|
||||||
$duration[1] = intval(($time/60)%60);
|
$duration[1] = intval(($time/60)%60);
|
||||||
$duration[2] = $time%60;
|
$duration[2] = $time%60;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($duration[2] == 0){
|
if($duration[2] == 0){
|
||||||
$duration[2] = '';
|
$duration[2] = '';
|
||||||
}else{
|
}else{
|
||||||
$duration[2] = intval($duration[2],10).'s';
|
$duration[2] = intval($duration[2],10).'s';
|
||||||
}
|
}
|
||||||
|
|
||||||
if($duration[1] == 0){
|
if($duration[1] == 0){
|
||||||
if($duration[2] == ''){
|
if($duration[2] == ''){
|
||||||
$duration[1] = '';
|
$duration[1] = '';
|
||||||
|
@ -144,13 +144,13 @@ class Application_Model_Nowplaying
|
||||||
}else{
|
}else{
|
||||||
$duration[1] = intval($duration[1],10).'m ';
|
$duration[1] = intval($duration[1],10).'m ';
|
||||||
}
|
}
|
||||||
|
|
||||||
if($duration[0] == 0){
|
if($duration[0] == 0){
|
||||||
$duration[0] = '';
|
$duration[0] = '';
|
||||||
}else{
|
}else{
|
||||||
$duration[0] = intval($duration[0],10).'h ';
|
$duration[0] = intval($duration[0],10).'h ';
|
||||||
}
|
}
|
||||||
|
|
||||||
$out = $duration[0].$duration[1].$duration[2];
|
$out = $duration[0].$duration[1].$duration[2];
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue