-began adding grouping by shows for the datatable.
This commit is contained in:
parent
d22ab329d8
commit
38856c4af7
|
@ -30,6 +30,10 @@ class Application_Model_DateHelper
|
|||
return $dayEndTS - $this->_timestamp;
|
||||
}
|
||||
|
||||
public static function TimeDiff($time1, $time2){
|
||||
return strtotime($time2) - strtotime($time1);
|
||||
}
|
||||
|
||||
public static function ConvertMSToHHMMSSmm($time){
|
||||
$hours = floor($time / 3600000);
|
||||
$time -= 3600000*$hours;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
class Application_Model_Nowplaying
|
||||
{
|
||||
|
||||
/*
|
||||
public static function InsertBlankRow($i, $rows){
|
||||
$startDateFull = $rows[$i-1][3];
|
||||
$endDateFull = $rows[$i][2];
|
||||
|
@ -44,6 +44,40 @@ class Application_Model_Nowplaying
|
|||
|
||||
return $rows;
|
||||
}
|
||||
*/
|
||||
|
||||
public static function FindGapsBetweenShows($showsMap){
|
||||
return $showsMap;
|
||||
}
|
||||
|
||||
public static function FindGapsAtEndOfShows($showsMap){
|
||||
foreach($showsMap as $k => $show){
|
||||
$showStartTime = $show['starts'];
|
||||
$showEndTime = $show['ends'];
|
||||
|
||||
//get the last songs end-time
|
||||
$items = $show['items'];
|
||||
if (count($items) > 1){
|
||||
$lastItem = $items[count($items)-1];
|
||||
$lastItemEndTime = $lastItem[3];
|
||||
} else {
|
||||
$lastItemEndTime = $showStartTime;
|
||||
}
|
||||
|
||||
$diff = Application_Model_DateHelper::TimeDiff($lastItemEndTime, $showEndTime);
|
||||
//echo $diff."-";
|
||||
if ($diff <= 0){
|
||||
//ok!
|
||||
} else {
|
||||
//There is a gap at the end of the show
|
||||
//insert blank row
|
||||
array_push($items, array("b", $diff, "-", "-", "-", "-", "-", "-", "-", "-", "-", "-"));
|
||||
$showsMap[$k]['items'] = $items;
|
||||
}
|
||||
}
|
||||
|
||||
return $showsMap;
|
||||
}
|
||||
|
||||
public static function GetDataGridData($viewType, $dateString){
|
||||
|
||||
|
@ -60,6 +94,8 @@ class Application_Model_Nowplaying
|
|||
$previous = array_reverse(Schedule::Get_Scheduled_Item_Data($timeNow, -1, 1, "60 seconds"));
|
||||
$current = Schedule::Get_Scheduled_Item_Data($timeNow, 0);
|
||||
$next = Schedule::Get_Scheduled_Item_Data($timeNow, 1, 10, "24 hours");
|
||||
|
||||
$showsMap = Show_DAL::GetShowsInRange($timeNow, "60 seconds", "24 hours");
|
||||
} else {
|
||||
$date = new Application_Model_DateHelper;
|
||||
$time = $date->getTime();
|
||||
|
@ -69,32 +105,38 @@ class Application_Model_Nowplaying
|
|||
$previous = array_reverse(Schedule::Get_Scheduled_Item_Data($timeNow, -1, "ALL", $date->getNowDayStartDiff()." seconds"));
|
||||
$current = Schedule::Get_Scheduled_Item_Data($timeNow, 0);
|
||||
$next = Schedule::Get_Scheduled_Item_Data($timeNow, 1, "ALL", $date->getNowDayEndDiff()." seconds");
|
||||
|
||||
$showsMap = Show_DAL::GetShowsInRange($timeNow, $date->getNowDayStartDiff(), $date->getNowDayEndDiff());
|
||||
}
|
||||
|
||||
$rows = array();
|
||||
//$rows = array();
|
||||
//print_r($showsMap);
|
||||
|
||||
foreach ($previous as $item){
|
||||
array_push($rows, array("p", $item["starts"], $item["starts"], $item["ends"], $item["clip_length"], $item["track_title"], $item["artist_name"],
|
||||
array_push($showsMap[$item["instance_id"]]['items'], array("p", $item["starts"], $item["starts"], $item["ends"], $item["clip_length"], $item["track_title"], $item["artist_name"],
|
||||
$item["album_title"], $item["name"], $item["show_name"], $item["instance_id"], $item["group_id"]));
|
||||
}
|
||||
|
||||
foreach ($current as $item){
|
||||
array_push($rows, array("c", $item["starts"], $item["starts"], $item["ends"], $item["clip_length"], $item["track_title"], $item["artist_name"],
|
||||
array_push($showsMap[$item["instance_id"]]['items'], array("c", $item["starts"], $item["starts"], $item["ends"], $item["clip_length"], $item["track_title"], $item["artist_name"],
|
||||
$item["album_title"], $item["name"], $item["show_name"], $item["instance_id"], $item["group_id"]));
|
||||
}
|
||||
|
||||
foreach ($next as $item){
|
||||
array_push($rows, array("n", $item["starts"], $item["starts"], $item["ends"], $item["clip_length"], $item["track_title"], $item["artist_name"],
|
||||
array_push($showsMap[$item["instance_id"]]['items'], array("n", $item["starts"], $item["starts"], $item["ends"], $item["clip_length"], $item["track_title"], $item["artist_name"],
|
||||
$item["album_title"], $item["name"], $item["show_name"], $item["instance_id"], $item["group_id"]));
|
||||
}
|
||||
|
||||
|
||||
$rows = Application_Model_Nowplaying::FindGaps($rows);
|
||||
|
||||
//$showsMap = Application_Model_Nowplaying::FindGapsBetweenShows($showsMap);
|
||||
$showsMap = Application_Model_Nowplaying::FindGapsAtEndOfShows($showsMap);
|
||||
|
||||
//$rows = Application_Model_Nowplaying::FindGaps($rows);
|
||||
$date = new Application_Model_DateHelper;
|
||||
$timeNow = $date->getDate();
|
||||
|
||||
$data = array("currentShow"=>Show_DAL::GetCurrentShow($timeNow), "rows"=>$rows);
|
||||
$data = array("currentShow"=>Show_DAL::GetCurrentShow($timeNow), "rows"=>$showsMap);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
|
|
@ -758,4 +758,32 @@ class Show_DAL{
|
|||
return $rows;
|
||||
}
|
||||
|
||||
public static function GetShowsInRange($timeNow, $start, $end){
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
$sql = "SELECT *,"
|
||||
." si.starts as start_timestamp,"
|
||||
." si.ends as end_timestamp,"
|
||||
." si.id as instance_id"
|
||||
." FROM "
|
||||
." $CC_CONFIG[showInstances] si,"
|
||||
." $CC_CONFIG[showTable] s"
|
||||
." WHERE si.show_id = s.id"
|
||||
." AND (si.ends > TIMESTAMP '$timeNow' - INTERVAL '$start seconds' OR si.starts < TIMESTAMP '$timeNow' + INTERVAL '$end seconds')"
|
||||
." ORDER BY si.starts";
|
||||
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
|
||||
$showsMap = array();
|
||||
$rowsCount = count($rows);
|
||||
|
||||
for ($i=0; $i<$rowsCount; $i++){
|
||||
$rows[$i]['items'] = array();
|
||||
array_push($rows[$i]['items'],
|
||||
array("s", $rows[$i]["starts"], $rows[$i]["starts"], $rows[$i]["ends"], "", "", "", "", "", $rows[$i]["name"], $rows[$i]["instance_id"], ""));
|
||||
$showsMap[$rows[$i]['instance_id']] = $rows[$i];
|
||||
}
|
||||
|
||||
return $showsMap;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
su -l pypo -c "tail -F /etc/service/pypo-fetch/log/main/current"
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
su -l pypo -c "tail -F /etc/service/pypo-liquidsoap/log/main/current"
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
su -l pypo -c "tail -F /etc/service/pypo-push/log/main/current"
|
|
@ -60,7 +60,7 @@ var columns = [{"sTitle": "type", "bVisible":false},
|
|||
{"sTitle":"Album"},
|
||||
{"sTitle":"Playlist"},
|
||||
{"sTitle":"Show"},
|
||||
{"sTitle":"bgcolor", "bVisible":false},
|
||||
{"sTitle":"instance_id", "bVisible":true},
|
||||
{"sTitle":"group_id", "bVisible":false}];
|
||||
|
||||
function getDateString(){
|
||||
|
@ -85,7 +85,9 @@ function updateDataTable(){
|
|||
//function can be called before ajax call has been returned.
|
||||
if (datagridData != null){
|
||||
table.fnClearTable(false);
|
||||
table.fnAddData(datagridData.rows, false);
|
||||
for (var show in datagridData.rows){
|
||||
table.fnAddData(datagridData.rows[show].items, false);
|
||||
}
|
||||
table.fnDraw(true);
|
||||
}
|
||||
}
|
||||
|
@ -133,6 +135,35 @@ function createDataGrid(){
|
|||
$(nRow).attr("class", "gap");
|
||||
return nRow;
|
||||
},
|
||||
"fnDrawCallback": function(oSettings){
|
||||
//check if there are any rows to display
|
||||
if (oSettings.aiDisplay.length == 0)
|
||||
return;
|
||||
|
||||
var nTrs = $('#nowplayingtable tbody tr');
|
||||
var iColspan = nTrs[0].getElementsByTagName('td').length;
|
||||
|
||||
for (var i=0; i<nTrs.length; i++){
|
||||
|
||||
var iDisplayIndex = oSettings._iDisplayStart + i;
|
||||
var sType = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex]]._aData[0];
|
||||
|
||||
var showName = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex]]._aData[9];
|
||||
var startTime = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex]]._aData[2];
|
||||
var endTime = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex]]._aData[3];
|
||||
|
||||
if ( sType == "s" ){
|
||||
var nGroup = document.createElement('tr');
|
||||
var nCell = document.createElement('td');
|
||||
nCell.colSpan = iColspan;
|
||||
nCell.className = "group";
|
||||
nCell.innerHTML = showName + ": " + startTime + " - " + endTime;
|
||||
nGroup.appendChild(nCell);
|
||||
nTrs[i].parentNode.replaceChild(nGroup, nTrs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
"bAutoWidth":false
|
||||
} );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue