CC-3331 : Optimize "Now Playing" to load in less than 1/2 second

- updated the CreateDatatableRows do perform a check and set on the last items end time. If the end time of the last item exceeds the show time's end I set the items end time to the show's end time.
This commit is contained in:
Daniel 2012-02-17 17:58:19 -05:00
parent c7f4b17e81
commit 664584ec6b
1 changed files with 20 additions and 7 deletions

View File

@ -12,15 +12,22 @@ class Application_Model_Nowplaying
$epochNow = time();
foreach ($p_dbRows as $dbRow) {
$showStartDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['show_starts']);
$showEndDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['show_ends']);
$itemStartDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['item_starts']);
$itemEndDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['item_ends']);
$lastRow = end($p_dbRows);
//Information about show is true for all rows in parameter so only check the last row's show
//start and end times.
if (isset($lastRow)){
$showStartDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($lastRow['show_starts']);
$showEndDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($lastRow['show_ends']);
$showStarts = $showStartDateTime->format("Y-m-d H:i:s");
$showEnds = $showEndDateTime->format("Y-m-d H:i:s");
}
foreach ($p_dbRows as $dbRow) {
$itemStartDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['item_starts']);
$itemEndDateTime = Application_Model_DateHelper::ConvertToLocalDateTime($dbRow['item_ends']);
$itemStarts = $itemStartDateTime->format("Y-m-d H:i:s");
$itemEnds = $itemEndDateTime->format("Y-m-d H:i:s");
@ -43,6 +50,12 @@ class Application_Model_Nowplaying
$dbRow['playlist_name'], $dbRow['show_name'], $status);
}
//Modify the last entry in the data table to adjust its end time to be equal to the
//shows end time if it exceeds it.
$lastRow = end($dataTablesRows);
if (isset($lastRow) && strtotime($showEnds) < strtotime($lastRow[3])){
$dataTablesRows[sizeof($dataTablesRows)-1][3] = $showEnds;
}
return $dataTablesRows;
}