Initial proof of concept for time remaining smart block limit
This commit is contained in:
parent
6031d95351
commit
c759f8b8aa
4 changed files with 33 additions and 7 deletions
|
@ -159,7 +159,8 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
|||
$this->limitOptions = array(
|
||||
"hours" => _("hours"),
|
||||
"minutes" => _("minutes"),
|
||||
"items" => _("items")
|
||||
"items" => _("items"),
|
||||
"remaining" => _("remaining time in show")
|
||||
);
|
||||
}
|
||||
return $this->limitOptions;
|
||||
|
|
|
@ -1310,9 +1310,13 @@ SQL;
|
|||
}
|
||||
}
|
||||
|
||||
public function getListOfFilesUnderLimit()
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
public function getListOfFilesUnderLimit($show = null)
|
||||
{
|
||||
$info = $this->getListofFilesMeetCriteria();
|
||||
$info = $this->getListofFilesMeetCriteria($show);
|
||||
$files = $info['files'];
|
||||
$limit = $info['limit'];
|
||||
$repeat = $info['repeat_tracks'];
|
||||
|
@ -1467,7 +1471,7 @@ SQL;
|
|||
}
|
||||
|
||||
// this function return list of propel object
|
||||
public function getListofFilesMeetCriteria()
|
||||
public function getListofFilesMeetCriteria($show = null)
|
||||
{
|
||||
$storedCrit = $this->getCriteria();
|
||||
|
||||
|
@ -1605,6 +1609,17 @@ SQL;
|
|||
if ($storedCrit['limit']['modifier'] == "items") {
|
||||
$limits['time'] = 1440 * 60;
|
||||
$limits['items'] = $storedCrit['limit']['value'];
|
||||
} elseif (($storedCrit['limit']['modifier'] == "remaining") ){
|
||||
// show will be null unless being called inside a show instance
|
||||
if (!(is_null($show))) {
|
||||
$showInstance = new Application_Model_ShowInstance($show);
|
||||
$limits['time'] = $showInstance->getSecondsRemaining();
|
||||
$limits['items'] = null;
|
||||
}
|
||||
else {
|
||||
$limits['time'] = 1440 * 60;
|
||||
$limits['items'] = null;
|
||||
}
|
||||
} else {
|
||||
$limits['time'] = $storedCrit['limit']['modifier'] == "hours" ?
|
||||
intval(floatval($storedCrit['limit']['value']) * 60 * 60) :
|
||||
|
|
|
@ -207,10 +207,11 @@ final class Application_Model_Scheduler
|
|||
/*
|
||||
* @param $id
|
||||
* @param $type
|
||||
* @param $show
|
||||
*
|
||||
* @return $files
|
||||
*/
|
||||
private function retrieveMediaFiles($id, $type)
|
||||
private function retrieveMediaFiles($id, $type, $show)
|
||||
{
|
||||
$files = array();
|
||||
|
||||
|
@ -337,7 +338,7 @@ final class Application_Model_Scheduler
|
|||
} else {
|
||||
$defaultFadeIn = Application_Model_Preference::GetDefaultFadeIn();
|
||||
$defaultFadeOut = Application_Model_Preference::GetDefaultFadeOut();
|
||||
$dynamicFiles = $bl->getListOfFilesUnderLimit();
|
||||
$dynamicFiles = $bl->getListOfFilesUnderLimit($show);
|
||||
foreach ($dynamicFiles as $f) {
|
||||
$fileId = $f['id'];
|
||||
$file = CcFilesQuery::create()->findPk($fileId);
|
||||
|
@ -788,11 +789,14 @@ final class Application_Model_Scheduler
|
|||
Logging::debug(floatval($pend) - floatval($pstart));
|
||||
}
|
||||
|
||||
// passing $schedule["instance"] so that the instance being scheduled
|
||||
// can be used to determine the remaining time
|
||||
// in the case of a fill remaining time smart block
|
||||
if (is_null($filesToInsert)) {
|
||||
$filesToInsert = array();
|
||||
foreach ($mediaItems as $media) {
|
||||
$filesToInsert = array_merge($filesToInsert,
|
||||
$this->retrieveMediaFiles($media["id"], $media["type"]));
|
||||
$this->retrieveMediaFiles($media["id"], $media["type"], $schedule["instance"]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -476,6 +476,12 @@ SQL;
|
|||
return intval($ends->format('U')) - intval($starts->format('U'));
|
||||
}
|
||||
|
||||
// should return the amount of seconds remaining to be scheduled in a show instance
|
||||
public function getSecondsRemaining()
|
||||
{
|
||||
return ($this->getDurationSecs() - $this->getTimeScheduledSecs());
|
||||
}
|
||||
|
||||
public function getPercentScheduled()
|
||||
{
|
||||
$durationSeconds = $this->getDurationSecs();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue