CC-3174 : showbuilder

using the new status column in cc_schedule to colour boundary/overbooked tracks.
This commit is contained in:
Naomi Aro 2012-03-01 15:09:13 +01:00
parent 0f9800a6bd
commit 3bfbe036c7
3 changed files with 21 additions and 37 deletions

View File

@ -237,6 +237,7 @@ class Application_Model_Schedule {
sched.starts AS sched_starts, sched.ends AS sched_ends, sched.id AS sched_id, sched.starts AS sched_starts, sched.ends AS sched_ends, sched.id AS sched_id,
sched.cue_in AS cue_in, sched.cue_out AS cue_out, sched.cue_in AS cue_in, sched.cue_out AS cue_out,
sched.fade_in AS fade_in, sched.fade_out AS fade_out, sched.fade_in AS fade_in, sched.fade_out AS fade_out,
sched.status AS sched_status,
ft.track_title AS file_track_title, ft.artist_name AS file_artist_name, ft.track_title AS file_track_title, ft.artist_name AS file_artist_name,
ft.album_title AS file_album_title, ft.length AS file_length ft.album_title AS file_album_title, ft.length AS file_length
@ -394,7 +395,7 @@ class Application_Model_Schedule {
} }
return $diff; return $diff;
} }
/** /**
* Returns array indexed by: * Returns array indexed by:
* "playlistId"/"playlist_id" (aliases to the same thing) * "playlistId"/"playlist_id" (aliases to the same thing)
@ -421,7 +422,7 @@ class Application_Model_Schedule {
public static function GetItems($p_currentDateTime, $p_toDateTime) { public static function GetItems($p_currentDateTime, $p_toDateTime) {
global $CC_CONFIG, $CC_DBC; global $CC_CONFIG, $CC_DBC;
$rows = array(); $rows = array();
$sql = "SELECT st.file_id AS file_id," $sql = "SELECT st.file_id AS file_id,"
." st.id as id," ." st.id as id,"
." st.starts AS start," ." st.starts AS start,"
@ -436,19 +437,19 @@ class Application_Model_Schedule {
." LEFT JOIN $CC_CONFIG[showInstances] as si" ." LEFT JOIN $CC_CONFIG[showInstances] as si"
." ON st.instance_id = si.id" ." ON st.instance_id = si.id"
." ORDER BY start"; ." ORDER BY start";
Logging::log($sql); Logging::log($sql);
$rows = $CC_DBC->GetAll($sql); $rows = $CC_DBC->GetAll($sql);
if (PEAR::isError($rows)) { if (PEAR::isError($rows)) {
return null; return null;
} }
return $rows; return $rows;
} }
public static function GetScheduledPlaylists($p_fromDateTime = null, $p_toDateTime = null){ public static function GetScheduledPlaylists($p_fromDateTime = null, $p_toDateTime = null){
global $CC_CONFIG, $CC_DBC; global $CC_CONFIG, $CC_DBC;
/* if $p_fromDateTime and $p_toDateTime function parameters are null, then set range /* if $p_fromDateTime and $p_toDateTime function parameters are null, then set range
@ -466,34 +467,34 @@ class Application_Model_Schedule {
} else { } else {
$range_end = Application_Model_Schedule::PypoTimeToAirtimeTime($p_toDateTime); $range_end = Application_Model_Schedule::PypoTimeToAirtimeTime($p_toDateTime);
} }
// Scheduler wants everything in a playlist // Scheduler wants everything in a playlist
$items = Application_Model_Schedule::GetItems($range_start, $range_end); $items = Application_Model_Schedule::GetItems($range_start, $range_end);
$data = array(); $data = array();
$utcTimeZone = new DateTimeZone("UTC"); $utcTimeZone = new DateTimeZone("UTC");
$data["status"] = array(); $data["status"] = array();
$data["media"] = array(); $data["media"] = array();
foreach ($items as $item){ foreach ($items as $item){
$storedFile = Application_Model_StoredFile::Recall($item["file_id"]); $storedFile = Application_Model_StoredFile::Recall($item["file_id"]);
$uri = $storedFile->getFileUrlUsingConfigAddress(); $uri = $storedFile->getFileUrlUsingConfigAddress();
$showEndDateTime = new DateTime($item["show_end"], $utcTimeZone); $showEndDateTime = new DateTime($item["show_end"], $utcTimeZone);
$trackEndDateTime = new DateTime($item["end"], $utcTimeZone); $trackEndDateTime = new DateTime($item["end"], $utcTimeZone);
/* Note: cue_out and end are always the same. */ /* Note: cue_out and end are always the same. */
/* TODO: Not all tracks will have "show_end" */ /* TODO: Not all tracks will have "show_end" */
if ($trackEndDateTime->getTimestamp() > $showEndDateTime->getTimestamp()){ if ($trackEndDateTime->getTimestamp() > $showEndDateTime->getTimestamp()){
$diff = $trackEndDateTime->getTimestamp() - $showEndDateTime->getTimestamp(); $diff = $trackEndDateTime->getTimestamp() - $showEndDateTime->getTimestamp();
//assuming ends takes cue_out into assumption //assuming ends takes cue_out into assumption
$item["cue_out"] = $item["cue_out"] - $diff; $item["cue_out"] = $item["cue_out"] - $diff;
} }
$start = Application_Model_Schedule::AirtimeTimeToPypoTime($item["start"]); $start = Application_Model_Schedule::AirtimeTimeToPypoTime($item["start"]);
$data["media"][$start] = array( $data["media"][$start] = array(
'id' => $storedFile->getGunid(), 'id' => $storedFile->getGunid(),
'row_id' => $item["id"], 'row_id' => $item["id"],
@ -506,7 +507,7 @@ class Application_Model_Schedule {
'end' => Application_Model_Schedule::AirtimeTimeToPypoTime($item["end"]) 'end' => Application_Model_Schedule::AirtimeTimeToPypoTime($item["end"])
); );
} }
return $data; return $data;
} }

View File

@ -86,27 +86,10 @@ class Application_Model_ShowBuilder {
} }
} }
//information about whether a track is inside|boundary|outside a show.
private function getItemStatus($p_item, &$row) { private function getItemStatus($p_item, &$row) {
$showEndDT = new DateTime($p_item["si_ends"]); $row["status"] = intval($p_item["sched_status"]);
$schedStartDT = new DateTime($p_item["sched_starts"]);
$schedEndDT = new DateTime($p_item["sched_ends"]);
$showEndEpoch = intval($showEndDT->format("U"));
$schedStartEpoch = intval($schedStartDT->format("U"));
$schedEndEpoch = intval($schedEndDT->format("U"));
if ($schedEndEpoch < $showEndEpoch) {
$status = 0; //item will playout in full
}
else if ($schedStartEpoch < $showEndEpoch && $schedEndEpoch > $showEndEpoch) {
$status = 1; //item is on boundry
}
else {
$status = 2; //item is overscheduled won't play.
}
$row["status"] = $status;
} }
private function getRowTimestamp($p_item, &$row) { private function getRowTimestamp($p_item, &$row) {

View File

@ -191,10 +191,10 @@ var AIRTIME = (function(AIRTIME){
} }
//status used to colour tracks. //status used to colour tracks.
if (aData.status === 1) { if (aData.status === 2) {
$(nRow).addClass("sb-boundry"); $(nRow).addClass("sb-boundry");
} }
else if (aData.status === 2) { else if (aData.status === 0) {
$(nRow).addClass("sb-over"); $(nRow).addClass("sb-over");
} }