early implementation of CC-1962

This commit is contained in:
martin 2011-03-06 00:08:02 -05:00
parent f4a86d96c6
commit e16dd6c486
8 changed files with 78 additions and 20 deletions

View File

@ -188,7 +188,7 @@ class ScheduleController extends Zend_Controller_Action
$this->view->showContent = $show->getShowContent();
$this->view->timeFilled = $show->getTimeScheduled();
$this->view->percentFilled = $show->getPercentScheduledInRange();
$this->view->percentFilled = $show->getPercentScheduled();
$this->view->chosen = $this->view->render('schedule/scheduled-content.phtml');
unset($this->view->showContent);
@ -237,7 +237,7 @@ class ScheduleController extends Zend_Controller_Action
$this->view->showContent = $show->getShowContent();
$this->view->timeFilled = $show->getTimeScheduled();
$this->view->percentFilled = $show->getPercentScheduledInRange();
$this->view->percentFilled = $show->getPercentScheduled();
$this->view->chosen = $this->view->render('schedule/scheduled-content.phtml');
unset($this->view->showContent);
}
@ -268,7 +268,7 @@ class ScheduleController extends Zend_Controller_Action
$this->view->timeFilled = $show->getTimeScheduled();
$this->view->showName = $show->getName();
$this->view->showLength = $show->getShowLength();
$this->view->percentFilled = $show->getPercentScheduledInRange();
$this->view->percentFilled = $show->getPercentScheduled();
$this->view->s_wday = $dateInfo_s['weekday'];
$this->view->s_month = $dateInfo_s['month'];

View File

@ -278,12 +278,11 @@ class Schedule {
return ($count == '0');
}
public static function getTimeUnScheduledInRange($s_datetime, $e_datetime) {
public static function getTimeUnScheduledInRange($instance_id, $s_datetime, $e_datetime) {
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT SUM(clip_length) FROM ".$CC_CONFIG["scheduleTable"]."
WHERE (starts >= '{$s_datetime}')
AND (ends <= '{$e_datetime}')";
$sql = "SELECT SUM(clip_length) FROM $CC_CONFIG[scheduleTable]"
." WHERE instance_id = $instance_id";
$time = $CC_DBC->GetOne($sql);
@ -313,6 +312,20 @@ class Schedule {
return $res;
}
public static function GetTotalShowTime($instance_id) {
global $CC_CONFIG, $CC_DBC;
$sql = "SELECT SUM(clip_length) FROM $CC_CONFIG[scheduleTable]"
." WHERE instance_id = $instance_id";
$res = $CC_DBC->GetOne($sql);
if(is_null($res))
return 0;
return $res;
}
public static function getPercentScheduledInRange($s_datetime, $e_datetime) {
@ -337,6 +350,25 @@ class Schedule {
return $percent;
}
public static function GetPercentScheduled($instance_id, $s_datetime, $e_datetime){
$time = Schedule::GetTotalShowTime($instance_id);
$s_epoch = strtotime($s_datetime);
$e_epoch = strtotime($e_datetime);
$con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
$sql = "SELECT EXTRACT(EPOCH FROM INTERVAL '{$time}')";
$r = $con->query($sql);
$i_epoch = $r->fetchColumn(0);
$percent = ceil(($i_epoch / ($e_epoch - $s_epoch)) * 100);
if ($percent > 100)
$percent = 100;
return $percent;
}
/**
* Return TRUE if file is going to be played in the future.
@ -490,7 +522,8 @@ class Schedule {
." WHERE st.playlist_id = pt.id"
." AND st.file_id = ft.id"
." AND st.instance_id = si.id"
." AND si.show_id = show.id";
." AND si.show_id = show.id"
." AND st.starts < si.ends";
if ($timePeriod < 0){
$sql .= " AND st.ends < TIMESTAMP '$timeStamp'"

View File

@ -456,6 +456,10 @@ class ShowInstance {
return $showInstance->getDbShowId();
}
public function getShowInstanceId() {
return $this->_instanceId;
}
public function getName() {
$show = CcShowQuery::create()->findPK($this->getShowId());
return $show->getDbName();
@ -635,11 +639,8 @@ class ShowInstance {
}
public function getTimeScheduled() {
$start_timestamp = $this->getShowStart();
$end_timestamp = $this->getShowEnd();
$time = Schedule::getTimeScheduledInRange($start_timestamp, $end_timestamp);
$instance_id = $this->getShowInstanceId();
$time = Schedule::GetTotalShowTime($instance_id);
return $time;
}
@ -648,8 +649,9 @@ class ShowInstance {
$start_timestamp = $this->getShowStart();
$end_timestamp = $this->getShowEnd();
$instance_id = $this->getShowInstanceId();
$time = Schedule::getTimeUnScheduledInRange($start_timestamp, $end_timestamp);
$time = Schedule::getTimeUnScheduledInRange($instance_id, $start_timestamp, $end_timestamp);
return $time;
}
@ -662,6 +664,14 @@ class ShowInstance {
return Schedule::getPercentScheduledInRange($start_timestamp, $end_timestamp);
}
public function getPercentScheduled(){
$start_timestamp = $this->getShowStart();
$end_timestamp = $this->getShowEnd();
$instance_id = $this->getShowInstanceId();
return Schedule::GetPercentScheduled($instance_id, $start_timestamp, $end_timestamp);
}
public function getShowLength(){
global $CC_DBC;
@ -794,6 +804,7 @@ class Show_DAL{
." WHERE ((si.starts < TIMESTAMP '$timeNow' - INTERVAL '$start seconds' AND si.ends > TIMESTAMP '$timeNow' - INTERVAL '$start seconds')"
." OR (si.starts > TIMESTAMP '$timeNow' - INTERVAL '$start seconds' AND si.ends < TIMESTAMP '$timeNow' + INTERVAL '$end seconds')"
." OR (si.starts < TIMESTAMP '$timeNow' + INTERVAL '$end seconds' AND si.ends > TIMESTAMP '$timeNow' + INTERVAL '$end seconds'))"
." AND (st.starts < si.ends)"
." ORDER BY st.starts";
return $CC_DBC->GetAll($sql);

View File

@ -1671,7 +1671,7 @@ class StoredFile {
$fromTable = "cc_playlist AS pl LEFT JOIN cc_playlisttimes AS plt USING(id) LEFT JOIN cc_subjs AS sub ON pl.editedby = sub.id";
$datatables["optWhere"][] = "plt.length <= INTERVAL '{$p_length}'";
$datatables["optWhere"][] = "INTERVAL '{$p_length}' > INTERVAL '00:00:00'";
$datatables["optWhere"][] = "plt.length > INTERVAL '00:00:00'";
return StoredFile::searchFiles($fromTable, $datatables);

View File

@ -28,6 +28,7 @@
<div id="show_progressbar"></div>
<span id="show_length" class="time"><?php echo $this->showLength; ?></span>
</div>
<div id="show_time_warning"></div>
</div>
</div>
</div>

View File

@ -22,6 +22,15 @@ function setScheduleDialogHtml(json) {
$("#show_time_filled").empty().append(json.timeFilled);
$("#show_progressbar").progressbar( "value" , json.percentFilled );
var showFilled = $("#show_time_filled").text().split('.')[0];
var showLength = $("#show_length").text();
if (showFilled > showLength){
$("#show_time_warning").text("Shows longer than their scheduled time will be cut off by a following show.");
} else {
$("#show_time_warning").empty();
}
}
function setScheduleDialogEvents(dialog) {

View File

@ -60,7 +60,7 @@ var columns = [{"sTitle": "type", "bVisible":false},
{"sTitle":"Album"},
{"sTitle":"Playlist"},
{"sTitle":"Show"},
{"sTitle":"instance_id", "bVisible":true}];
{"sTitle":"instance_id", "bVisible":false}];
function getDateString(){
var date0 = $("#datepicker").datepicker("getDate");

View File

@ -39,10 +39,14 @@ end
# by default
def add_skip_command(s)
# A command to skip
def skip(_)
source.skip(s)
"Done!"
end
def skip(_)
l = list.hd(server.execute("queue.queue"))
l = string.split(separator=" ",l)
list.iter(fun (rid) -> ignore(server.execute(queue.ignore #{rid}")), l)
source.skip(s)
"Done!"
end
# Register the command:
server.register(namespace="source",
usage="skip",