CC-4639: Give an option to allow smart blocks to reuse tracks if not enough tracks meet the time limit.
- done
This commit is contained in:
parent
00947f9d7e
commit
9d495ebc03
6 changed files with 99 additions and 10 deletions
|
@ -513,6 +513,7 @@ class PlaylistController extends Zend_Controller_Action
|
||||||
} catch (BlockNotFoundException $e) {
|
} catch (BlockNotFoundException $e) {
|
||||||
$this->playlistNotFound('block', true);
|
$this->playlistNotFound('block', true);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
Logging::info($e);
|
||||||
$this->playlistUnknownError($e);
|
$this->playlistUnknownError($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,6 +212,14 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
||||||
|
|
||||||
}//for
|
}//for
|
||||||
|
|
||||||
|
$repeatTracks = new Zend_Form_Element_Checkbox('sp_repeat_tracks');
|
||||||
|
$repeatTracks->setDecorators(array('viewHelper'))
|
||||||
|
->setLabel('Allow Repeat Tracks:');
|
||||||
|
if (isset($storedCrit["repeat_tracks"])) {
|
||||||
|
$repeatTracks->setChecked($storedCrit["repeat_tracks"]["value"] == 1?true:false);
|
||||||
|
}
|
||||||
|
$this->addElement($repeatTracks);
|
||||||
|
|
||||||
$limit = new Zend_Form_Element_Select('sp_limit_options');
|
$limit = new Zend_Form_Element_Select('sp_limit_options');
|
||||||
$limit->setAttrib('class', 'sp_input_select')
|
$limit->setAttrib('class', 'sp_input_select')
|
||||||
->setDecorators(array('viewHelper'))
|
->setDecorators(array('viewHelper'))
|
||||||
|
@ -220,7 +228,7 @@ class Application_Form_SmartBlockCriteria extends Zend_Form_SubForm
|
||||||
$limit->setValue($storedCrit["limit"]["modifier"]);
|
$limit->setValue($storedCrit["limit"]["modifier"]);
|
||||||
}
|
}
|
||||||
$this->addElement($limit);
|
$this->addElement($limit);
|
||||||
|
|
||||||
$limitValue = new Zend_Form_Element_Text('sp_limit_value');
|
$limitValue = new Zend_Form_Element_Text('sp_limit_value');
|
||||||
$limitValue->setAttrib('class', 'sp_input_text_limit')
|
$limitValue->setAttrib('class', 'sp_input_text_limit')
|
||||||
->setLabel('Limit to')
|
->setLabel('Limit to')
|
||||||
|
|
|
@ -1093,6 +1093,14 @@ SQL;
|
||||||
->setDbValue($p_criteriaData['etc']['sp_limit_value'])
|
->setDbValue($p_criteriaData['etc']['sp_limit_value'])
|
||||||
->setDbBlockId($this->id)
|
->setDbBlockId($this->id)
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
|
// insert repeate track option
|
||||||
|
$qry = new CcBlockcriteria();
|
||||||
|
$qry->setDbCriteria("repeat_tracks")
|
||||||
|
->setDbModifier("N/A")
|
||||||
|
->setDbValue($p_criteriaData['etc']['sp_repeat_tracks'])
|
||||||
|
->setDbBlockId($this->id)
|
||||||
|
->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1105,7 +1113,7 @@ SQL;
|
||||||
$this->saveSmartBlockCriteria($p_criteria);
|
$this->saveSmartBlockCriteria($p_criteria);
|
||||||
$insertList = $this->getListOfFilesUnderLimit();
|
$insertList = $this->getListOfFilesUnderLimit();
|
||||||
$this->deleteAllFilesFromBlock();
|
$this->deleteAllFilesFromBlock();
|
||||||
$this->addAudioClips(array_keys($insertList));
|
$this->addAudioClips(array_values($insertList));
|
||||||
// update length in playlist contents.
|
// update length in playlist contents.
|
||||||
$this->updateBlockLengthInAllPlaylist();
|
$this->updateBlockLengthInAllPlaylist();
|
||||||
|
|
||||||
|
@ -1134,6 +1142,7 @@ SQL;
|
||||||
$info = $this->getListofFilesMeetCriteria();
|
$info = $this->getListofFilesMeetCriteria();
|
||||||
$files = $info['files'];
|
$files = $info['files'];
|
||||||
$limit = $info['limit'];
|
$limit = $info['limit'];
|
||||||
|
$repeat = $info['repeat_tracks'];
|
||||||
|
|
||||||
$insertList = array();
|
$insertList = array();
|
||||||
$totalTime = 0;
|
$totalTime = 0;
|
||||||
|
@ -1142,19 +1151,45 @@ SQL;
|
||||||
// this moves the pointer to the first element in the collection
|
// this moves the pointer to the first element in the collection
|
||||||
$files->getFirst();
|
$files->getFirst();
|
||||||
$iterator = $files->getIterator();
|
$iterator = $files->getIterator();
|
||||||
while ($iterator->valid() && $totalTime < $limit['time']) {
|
|
||||||
|
$isBlockFull = false;
|
||||||
|
|
||||||
|
while ($iterator->valid()) {
|
||||||
$id = $iterator->current()->getDbId();
|
$id = $iterator->current()->getDbId();
|
||||||
$length = Application_Common_DateHelper::calculateLengthInSeconds($iterator->current()->getDbLength());
|
$length = Application_Common_DateHelper::calculateLengthInSeconds($iterator->current()->getDbLength());
|
||||||
$insertList[$id] = $length;
|
$insertList[] = $id;
|
||||||
$totalTime += $length;
|
$totalTime += $length;
|
||||||
$totalItems++;
|
$totalItems++;
|
||||||
|
|
||||||
if ((!is_null($limit['items']) && $limit['items'] == count($insertList)) || $totalItems > 500) {
|
if ((!is_null($limit['items']) && $limit['items'] == count($insertList)) || $totalItems > 500 || $totalTime > $limit['time']) {
|
||||||
break;
|
$isBlockFull = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$iterator->next();
|
$iterator->next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if block is not full and reapeat_track is check, fill up more
|
||||||
|
while (!$isBlockFull && $repeat == 1) {
|
||||||
|
if (!$iterator->valid()) {
|
||||||
|
$iterator->closeCursor();
|
||||||
|
$info = $this->getListofFilesMeetCriteria();
|
||||||
|
$files = $info['files'];
|
||||||
|
$files->getFirst();
|
||||||
|
$iterator = $files->getIterator();
|
||||||
|
}
|
||||||
|
$id = $iterator->current()->getDbId();
|
||||||
|
$length = Application_Common_DateHelper::calculateLengthInSeconds($iterator->current()->getDbLength());
|
||||||
|
$insertList[] = $id;
|
||||||
|
$totalTime += $length;
|
||||||
|
$totalItems++;
|
||||||
|
|
||||||
|
if ((!is_null($limit['items']) && $limit['items'] == count($insertList)) || $totalItems > 500 || $totalTime > $limit['time']) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$iterator->next();
|
||||||
|
}
|
||||||
|
|
||||||
return $insertList;
|
return $insertList;
|
||||||
}
|
}
|
||||||
|
@ -1202,6 +1237,8 @@ SQL;
|
||||||
|
|
||||||
if ($criteria == "limit") {
|
if ($criteria == "limit") {
|
||||||
$storedCrit["limit"] = array("value"=>$value, "modifier"=>$modifier);
|
$storedCrit["limit"] = array("value"=>$value, "modifier"=>$modifier);
|
||||||
|
} else if($criteria == "repeat_tracks") {
|
||||||
|
$storedCrit["repeat_tracks"] = array("value"=>$value);
|
||||||
} else {
|
} else {
|
||||||
$storedCrit["crit"][$criteria][] = array("criteria"=>$criteria, "value"=>$value, "modifier"=>$modifier, "extra"=>$extra, "display_name"=>$criteriaOptions[$criteria]);
|
$storedCrit["crit"][$criteria][] = array("criteria"=>$criteria, "value"=>$value, "modifier"=>$modifier, "extra"=>$extra, "display_name"=>$criteriaOptions[$criteria]);
|
||||||
}
|
}
|
||||||
|
@ -1317,6 +1354,7 @@ SQL;
|
||||||
}
|
}
|
||||||
// construct limit restriction
|
// construct limit restriction
|
||||||
$limits = array();
|
$limits = array();
|
||||||
|
|
||||||
if (isset($storedCrit['limit'])) {
|
if (isset($storedCrit['limit'])) {
|
||||||
if ($storedCrit['limit']['modifier'] == "items") {
|
if ($storedCrit['limit']['modifier'] == "items") {
|
||||||
$limits['time'] = 1440 * 60;
|
$limits['time'] = 1440 * 60;
|
||||||
|
@ -1328,10 +1366,16 @@ SQL;
|
||||||
$limits['items'] = null;
|
$limits['items'] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$repeatTracks = 0;
|
||||||
|
if (isset($storedCrit['repeat_tracks'])) {
|
||||||
|
$repeatTracks = $storedCrit['repeat_tracks']['value'];
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$out = $qry->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)->find();
|
$out = $qry->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)->find();
|
||||||
|
|
||||||
return array("files"=>$out, "limit"=>$limits, "count"=>$out->count());
|
return array("files"=>$out, "limit"=>$limits, "repeat_tracks"=> $repeatTracks, "count"=>$out->count());
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Logging::info($e);
|
Logging::info($e);
|
||||||
}
|
}
|
||||||
|
@ -1377,7 +1421,7 @@ SQL;
|
||||||
$output['etc'][$ele['name']] = $ele['value'];
|
$output['etc'][$ele['name']] = $ele['value'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
// smart block functions end
|
// smart block functions end
|
||||||
|
|
|
@ -59,6 +59,20 @@
|
||||||
<br />
|
<br />
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
|
<dd id='sp_repeate_tracks-element'>
|
||||||
|
<span class='sp_text_font'><?php echo $this->element->getElement('sp_repeat_tracks')->getLabel() ?></span>
|
||||||
|
<span class='repeat_tracks_help_icon'></span>
|
||||||
|
<?php echo $this->element->getElement('sp_repeat_tracks')?>
|
||||||
|
<?php if($this->element->getElement("sp_repeat_tracks")->hasErrors()) : ?>
|
||||||
|
<?php foreach($this->element->getElement("sp_repeat_tracks")->getMessages() as $error): ?>
|
||||||
|
<span class='errors sp-errors'>
|
||||||
|
<?php echo $error; ?>
|
||||||
|
</span>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
<br />
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dd id='sp_limit-element'>
|
<dd id='sp_limit-element'>
|
||||||
<span class='sp_text_font'><?php echo $this->element->getElement('sp_limit_value')->getLabel() ?></span>
|
<span class='sp_text_font'><?php echo $this->element->getElement('sp_limit_value')->getLabel() ?></span>
|
||||||
<?php echo $this->element->getElement('sp_limit_value')?>
|
<?php echo $this->element->getElement('sp_limit_value')?>
|
||||||
|
|
|
@ -105,7 +105,7 @@ select {
|
||||||
}
|
}
|
||||||
|
|
||||||
.airtime_auth_help_icon, .custom_auth_help_icon, .stream_username_help_icon,
|
.airtime_auth_help_icon, .custom_auth_help_icon, .stream_username_help_icon,
|
||||||
.playlist_type_help_icon, .master_username_help_icon {
|
.playlist_type_help_icon, .master_username_help_icon, .repeat_tracks_help_icon{
|
||||||
cursor: help;
|
cursor: help;
|
||||||
position: relative;
|
position: relative;
|
||||||
display:inline-block; zoom:1;
|
display:inline-block; zoom:1;
|
||||||
|
|
|
@ -384,6 +384,28 @@ function setupUI() {
|
||||||
at: "right center"
|
at: "right center"
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(".repeat_tracks_help_icon").qtip({
|
||||||
|
content: {
|
||||||
|
text: "If your criteria is too strict, Airtime may not be able to fill up the desired smart block length." +
|
||||||
|
" Hence, if you check this option, tracks will be used more than once."
|
||||||
|
},
|
||||||
|
hide: {
|
||||||
|
delay: 500,
|
||||||
|
fixed: true
|
||||||
|
},
|
||||||
|
style: {
|
||||||
|
border: {
|
||||||
|
width: 0,
|
||||||
|
radius: 4
|
||||||
|
},
|
||||||
|
classes: "ui-tooltip-dark ui-tooltip-rounded"
|
||||||
|
},
|
||||||
|
position: {
|
||||||
|
my: "left bottom",
|
||||||
|
at: "right center"
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function enableAndShowExtraField(valEle, index) {
|
function enableAndShowExtraField(valEle, index) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue