CC-1665: Scheduled stream rebroadcasting and recording
-fix creator id on another SQL query
This commit is contained in:
parent
8876b312fb
commit
db36870aec
1 changed files with 47 additions and 42 deletions
|
@ -44,7 +44,7 @@ class Application_Model_Schedule
|
||||||
$previousShowID = count($shows['previousShow'])>0?$shows['previousShow'][0]['instance_id']:null;
|
$previousShowID = count($shows['previousShow'])>0?$shows['previousShow'][0]['instance_id']:null;
|
||||||
$currentShowID = count($shows['currentShow'])>0?$shows['currentShow'][0]['instance_id']:null;
|
$currentShowID = count($shows['currentShow'])>0?$shows['currentShow'][0]['instance_id']:null;
|
||||||
$nextShowID = count($shows['nextShow'])>0?$shows['nextShow'][0]['instance_id']:null;
|
$nextShowID = count($shows['nextShow'])>0?$shows['nextShow'][0]['instance_id']:null;
|
||||||
$results = Application_Model_Schedule::GetPrevCurrentNext($previousShowID, $currentShowID, $nextShowID, $utcTimeNow);
|
$results = self::GetPrevCurrentNext($previousShowID, $currentShowID, $nextShowID, $utcTimeNow);
|
||||||
|
|
||||||
$range = array("env"=>APPLICATION_ENV,
|
$range = array("env"=>APPLICATION_ENV,
|
||||||
"schedulerTime"=>$timeNow,
|
"schedulerTime"=>$timeNow,
|
||||||
|
@ -69,31 +69,36 @@ class Application_Model_Schedule
|
||||||
**/
|
**/
|
||||||
public static function GetPrevCurrentNext($p_previousShowID, $p_currentShowID, $p_nextShowID, $p_timeNow)
|
public static function GetPrevCurrentNext($p_previousShowID, $p_currentShowID, $p_nextShowID, $p_timeNow)
|
||||||
{
|
{
|
||||||
if ($p_previousShowID == null && $p_currentShowID == null && $p_nextShowID == null)
|
if ($p_previousShowID == null && $p_currentShowID == null && $p_nextShowID == null) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
global $CC_CONFIG;
|
global $CC_CONFIG;
|
||||||
$con = Propel::getConnection();
|
$con = Propel::getConnection();
|
||||||
$sql = "SELECT %%columns%% st.starts as starts, st.ends as ends, st.media_item_played as media_item_played, si.ends as show_ends
|
$sql = "SELECT %%columns%% st.starts as starts, st.ends as ends,
|
||||||
FROM cc_schedule st JOIN %%tables%% LEFT JOIN cc_show_instances si ON st.instance_id = si.id
|
st.media_item_played as media_item_played, si.ends as show_ends
|
||||||
WHERE ";
|
%%tables%% WHERE ";
|
||||||
|
|
||||||
$fileColumns = "ft.artist_name, ft.track_title, ";
|
$fileColumns = "ft.artist_name, ft.track_title, ";
|
||||||
$streamColumns = "ws.creator_id as artist_name, ws.name as track_title, ";
|
//$fileJoin = "cc_files ft ON st.file_id = ft.id";
|
||||||
|
$fileJoin = "FROM cc_schedule st JOIN cc_files ft ON st.file_id = ft.id
|
||||||
|
LEFT JOIN cc_show_instances si ON st.instance_id = si.id";
|
||||||
|
|
||||||
$fileJoin = "cc_files ft ON st.file_id = ft.id";
|
$streamColumns = "sub.login as artist_name, ws.name as track_title, ";
|
||||||
$streamJoin = "cc_webstream ws ON st.stream_id = ws.id";
|
//$streamJoin = "cc_webstream ws ON st.stream_id = ws.id";
|
||||||
|
$streamJoin = "FROM cc_schedule st JOIN cc_webstream ws ON st.stream_id = ws.id
|
||||||
|
LEFT JOIN cc_show_instances si ON st.instance_id = si.id
|
||||||
|
LEFT JOIN cc_subjs as sub on sub.id = ws.creator_id";
|
||||||
|
|
||||||
$predicateArr = array();
|
$predicateArr = array();
|
||||||
if (isset($p_previousShowID)) {
|
if (isset($p_previousShowID)) {
|
||||||
$predicateArr[] = 'st.instance_id = '.$p_previousShowID;
|
$predicateArr[] = 'st.instance_id = '.$p_previousShowID;
|
||||||
}
|
}
|
||||||
if (isset($p_currentShowID)) {
|
if (isset($p_currentShowID)) {
|
||||||
$predicateArr[] = 'st.instance_id = '.$p_currentShowID;
|
$predicateArr[] = 'st.instance_id = '.$p_currentShowID;
|
||||||
}
|
}
|
||||||
if (isset($p_nextShowID)) {
|
if (isset($p_nextShowID)) {
|
||||||
$predicateArr[] = 'st.instance_id = '.$p_nextShowID;
|
$predicateArr[] = 'st.instance_id = '.$p_nextShowID;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql .= " (".implode(" OR ", $predicateArr).") ";
|
$sql .= " (".implode(" OR ", $predicateArr).") ";
|
||||||
|
@ -123,36 +128,36 @@ class Application_Model_Schedule
|
||||||
|
|
||||||
|
|
||||||
if ((strtotime($rows[$i]['starts']) <= $timeNowAsMillis) && (strtotime($rows[$i]['ends']) >= $timeNowAsMillis)) {
|
if ((strtotime($rows[$i]['starts']) <= $timeNowAsMillis) && (strtotime($rows[$i]['ends']) >= $timeNowAsMillis)) {
|
||||||
if ($i - 1 >= 0) {
|
if ($i - 1 >= 0) {
|
||||||
$results['previous'] = array("name"=>$rows[$i-1]["artist_name"]." - ".$rows[$i-1]["track_title"],
|
$results['previous'] = array("name"=>$rows[$i-1]["artist_name"]." - ".$rows[$i-1]["track_title"],
|
||||||
"starts"=>$rows[$i-1]["starts"],
|
"starts"=>$rows[$i-1]["starts"],
|
||||||
"ends"=>$rows[$i-1]["ends"],
|
"ends"=>$rows[$i-1]["ends"],
|
||||||
"type"=>'track');
|
"type"=>'track');
|
||||||
}
|
}
|
||||||
$results['current'] = array("name"=>$rows[$i]["artist_name"]." - ".$rows[$i]["track_title"],
|
$results['current'] = array("name"=>$rows[$i]["artist_name"]." - ".$rows[$i]["track_title"],
|
||||||
"starts"=>$rows[$i]["starts"],
|
"starts"=>$rows[$i]["starts"],
|
||||||
"ends"=> (($rows[$i]["ends"] > $rows[$i]["show_ends"]) ? $rows[$i]["show_ends"]: $rows[$i]["ends"]),
|
"ends"=> (($rows[$i]["ends"] > $rows[$i]["show_ends"]) ? $rows[$i]["show_ends"]: $rows[$i]["ends"]),
|
||||||
"media_item_played"=>$rows[$i]["media_item_played"],
|
"media_item_played"=>$rows[$i]["media_item_played"],
|
||||||
"record"=>0,
|
"record"=>0,
|
||||||
"type"=>'track');
|
"type"=>'track');
|
||||||
if ( isset($rows[$i+1])) {
|
if (isset($rows[$i+1])) {
|
||||||
$results['next'] = array("name"=>$rows[$i+1]["artist_name"]." - ".$rows[$i+1]["track_title"],
|
$results['next'] = array("name"=>$rows[$i+1]["artist_name"]." - ".$rows[$i+1]["track_title"],
|
||||||
"starts"=>$rows[$i+1]["starts"],
|
"starts"=>$rows[$i+1]["starts"],
|
||||||
"ends"=>$rows[$i+1]["ends"],
|
"ends"=>$rows[$i+1]["ends"],
|
||||||
"type"=>'track');
|
"type"=>'track');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (strtotime($rows[$i]['ends']) < $timeNowAsMillis ) {
|
if (strtotime($rows[$i]['ends']) < $timeNowAsMillis ) {
|
||||||
$previousIndex = $i;
|
$previousIndex = $i;
|
||||||
}
|
}
|
||||||
if (strtotime($rows[$i]['starts']) > $timeNowAsMillis) {
|
if (strtotime($rows[$i]['starts']) > $timeNowAsMillis) {
|
||||||
$results['next'] = array("name"=>$rows[$i]["artist_name"]." - ".$rows[$i]["track_title"],
|
$results['next'] = array("name"=>$rows[$i]["artist_name"]." - ".$rows[$i]["track_title"],
|
||||||
"starts"=>$rows[$i]["starts"],
|
"starts"=>$rows[$i]["starts"],
|
||||||
"ends"=>$rows[$i]["ends"],
|
"ends"=>$rows[$i]["ends"],
|
||||||
"type"=>'track');
|
"type"=>'track');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//If we didn't find a a current show because the time didn't fit we may still have
|
//If we didn't find a a current show because the time didn't fit we may still have
|
||||||
//found a previous show so use it.
|
//found a previous show so use it.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue