SAAS-877 - Fix live-info-v2 behaviour

This commit is contained in:
Duncan Sommerville 2015-06-24 14:28:04 -04:00
parent ef957fe0aa
commit 616cf143d5
1 changed files with 44 additions and 42 deletions

View File

@ -6,6 +6,7 @@ class Application_Model_Schedule
const MASTER_SOURCE_NAME = "Master"; const MASTER_SOURCE_NAME = "Master";
const SHOW_SOURCE_NAME = "Live"; const SHOW_SOURCE_NAME = "Live";
const SCHEDULED_SOURCE_NAME = "Scheduled"; const SCHEDULED_SOURCE_NAME = "Scheduled";
const LIVE_STREAM = "Live Stream";
/** /**
* Return TRUE if file is going to be played in the future. * Return TRUE if file is going to be played in the future.
@ -168,7 +169,7 @@ SQL;
* *
* @param $utcNow DateTime current time in UTC * @param $utcNow DateTime current time in UTC
* @param $currentShowInstanceId int id of the show instance currently playing * @param $currentShowInstanceId int id of the show instance currently playing
* @param $source string id of the show instance currently playing * @param $source string the current prioritized source
* @return array with data about the previous, current, and next media items playing. * @return array with data about the previous, current, and next media items playing.
* Returns an empty arrays if there is no media item currently playing * Returns an empty arrays if there is no media item currently playing
*/ */
@ -195,22 +196,19 @@ SQL;
$rows = Application_Common_Database::prepareAndExecute($sql, $params); $rows = Application_Common_Database::prepareAndExecute($sql, $params);
// If live streaming (master or show source) is enabled, set the current
// track information to the current show values
if ($source != self::SCHEDULED_SOURCE_NAME) { if ($source != self::SCHEDULED_SOURCE_NAME) {
$show = Application_Model_Show::getCurrentShow(); $show = Application_Model_Show::getCurrentShow();
$results["current"] = array( $results["current"] = array(
"starts" => $show[0]["starts"], "starts" => $show[0]["starts"],
"ends" => $show[0]["ends"], "ends" => $show[0]["ends"],
"type" => _($source . " Stream"), "type" => _("livestream"),
"name" => (isset($show[0])?$show[0]["name"]:"") . " - " . _($source . " Stream"), "name" => (isset($show[0])?$show[0]["name"]:"") . " - " . _(self::LIVE_STREAM),
"media_item_played" => false, "media_item_played" => false,
"record" => "0" "record" => "0"
); );
} } else if (count($rows) >= 1) {
if (count($rows) < 1 || $rows[0]["show_ends"] < $utcNow->format(DEFAULT_TIMESTAMP_FORMAT)) {
return $results;
}
$currentMedia = $rows[0]; $currentMedia = $rows[0];
if ($currentMedia["ends"] > $currentMedia["show_ends"]) { if ($currentMedia["ends"] > $currentMedia["show_ends"]) {
@ -242,7 +240,6 @@ SQL;
$currentMediaType = null; $currentMediaType = null;
} }
if (is_null($results["current"])) {
$results["current"] = array( $results["current"] = array(
"starts" => $currentMedia["starts"], "starts" => $currentMedia["starts"],
"ends" => $currentMedia["ends"], "ends" => $currentMedia["ends"],
@ -254,8 +251,7 @@ SQL;
} }
$previousMedia = CcScheduleQuery::create() $previousMedia = CcScheduleQuery::create()
->filterByDbStarts($currentMedia["starts"], Criteria::LESS_THAN) ->filterByDbEnds($utcNow, Criteria::LESS_THAN)
->filterByDbId($currentMedia["id"], Criteria::NOT_EQUAL)
->filterByDbPlayoutStatus(0, Criteria::GREATER_THAN) ->filterByDbPlayoutStatus(0, Criteria::GREATER_THAN)
->orderByDbStarts(Criteria::DESC) ->orderByDbStarts(Criteria::DESC)
->findOne(); ->findOne();
@ -287,8 +283,7 @@ SQL;
} }
$nextMedia = CcScheduleQuery::create() $nextMedia = CcScheduleQuery::create()
->filterByDbStarts($currentMedia["starts"], Criteria::GREATER_THAN) ->filterByDbStarts($utcNow, Criteria::GREATER_THAN)
->filterByDbId($currentMedia["id"], Criteria::NOT_EQUAL)
->filterByDbPlayoutStatus(0, Criteria::GREATER_THAN) ->filterByDbPlayoutStatus(0, Criteria::GREATER_THAN)
->orderByDbStarts(Criteria::ASC) ->orderByDbStarts(Criteria::ASC)
->findOne(); ->findOne();
@ -322,6 +317,13 @@ SQL;
} }
/**
* Get the current prioritized source
*
* Priority order is Master->Live/Show->Scheduled.
*
* @return string the source name
*/
private static function _getSource() { private static function _getSource() {
$live_dj = Application_Model_Preference::GetSourceStatus("live_dj"); $live_dj = Application_Model_Preference::GetSourceStatus("live_dj");
$master_dj = Application_Model_Preference::GetSourceStatus("master_dj"); $master_dj = Application_Model_Preference::GetSourceStatus("master_dj");