feat(legacy): trim overbooked shows after autoloading a playlist (#2897)
### Description Some combination of preload/postload and autoloding playlists with smartblocks generate massively overbooked shows that clutter up the interface. This addition performs a 'trim overbooked' after filling up the autoload list, and does the same as pushing the 'trim overbooked' button in the UI. ### Testing Notes Define an autoloading playlist of 2 hours and schedule it for a one hour show. Without patch, you'll get entries for 2 hours, with the patch, you only get one hour and a 'overboarding' orange entry at most. --------- Co-authored-by: Kyle Robbertze <paddatrapper@users.noreply.github.com> Co-authored-by: Thomas Göttgens <tgoettgens@mail.com> Co-authored-by: jo <ljonas@riseup.net>
This commit is contained in:
parent
170d09545e
commit
a95ce3d229
|
@ -81,6 +81,11 @@ class AutoPlaylistManager
|
||||||
$si->addPlaylistToShow($outroplaylistid, false);
|
$si->addPlaylistToShow($outroplaylistid, false);
|
||||||
}
|
}
|
||||||
$si->setAutoPlaylistBuilt(true);
|
$si->setAutoPlaylistBuilt(true);
|
||||||
|
|
||||||
|
// now trim excessively overbooked shows so the display isn't cluttered with myriads of red off-time blocks
|
||||||
|
if (Application_Model_Preference::getScheduleTrimOverbooked()) {
|
||||||
|
$si->trimOverbooked();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Application_Model_Preference::setAutoPlaylistPollLock(microtime(true));
|
Application_Model_Preference::setAutoPlaylistPollLock(microtime(true));
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@ class PreferenceController extends Zend_Controller_Action
|
||||||
Application_Model_Preference::SetAllow3rdPartyApi($values['thirdPartyApi']);
|
Application_Model_Preference::SetAllow3rdPartyApi($values['thirdPartyApi']);
|
||||||
Application_Model_Preference::SetDefaultLocale($values['locale']);
|
Application_Model_Preference::SetDefaultLocale($values['locale']);
|
||||||
Application_Model_Preference::SetWeekStartDay($values['weekStartDay']);
|
Application_Model_Preference::SetWeekStartDay($values['weekStartDay']);
|
||||||
|
Application_Model_Preference::setScheduleTrimOverbooked($values['scheduleTrimOverbooked']);
|
||||||
Application_Model_Preference::setRadioPageDisplayLoginButton($values['radioPageLoginButton']);
|
Application_Model_Preference::setRadioPageDisplayLoginButton($values['radioPageLoginButton']);
|
||||||
Application_Model_Preference::setRadioPageDisabled($values['radioPageDisabled']);
|
Application_Model_Preference::setRadioPageDisabled($values['radioPageDisabled']);
|
||||||
Application_Model_Preference::SetFeaturePreviewMode($values['featurePreviewMode']);
|
Application_Model_Preference::SetFeaturePreviewMode($values['featurePreviewMode']);
|
||||||
|
|
|
@ -150,6 +150,18 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
|
||||||
]);
|
]);
|
||||||
$this->addElement($podcast_auto_smartblock);
|
$this->addElement($podcast_auto_smartblock);
|
||||||
|
|
||||||
|
$scheduleTrimOverbooked = new Zend_Form_Element_Checkbox('scheduleTrimOverbooked');
|
||||||
|
$scheduleTrimOverbooked->setDecorators([
|
||||||
|
'ViewHelper',
|
||||||
|
'Errors',
|
||||||
|
'Label',
|
||||||
|
]);
|
||||||
|
$displayScheduleTrimOverbookedValue = Application_Model_Preference::getScheduleTrimOverbooked();
|
||||||
|
$scheduleTrimOverbooked->addDecorator('Label');
|
||||||
|
$scheduleTrimOverbooked->setLabel(_('Trim overbooked shows after autoloading?'));
|
||||||
|
$scheduleTrimOverbooked->setValue($displayScheduleTrimOverbookedValue);
|
||||||
|
$this->addElement($scheduleTrimOverbooked);
|
||||||
|
|
||||||
// TODO add and insert Podcast Smartblock and Playlist autogenerate options
|
// TODO add and insert Podcast Smartblock and Playlist autogenerate options
|
||||||
|
|
||||||
$third_party_api = new Zend_Form_Element_Radio('thirdPartyApi');
|
$third_party_api = new Zend_Form_Element_Radio('thirdPartyApi');
|
||||||
|
|
|
@ -1399,6 +1399,16 @@ class Application_Model_Preference
|
||||||
self::setValue('radio_page_display_login_button', $value);
|
self::setValue('radio_page_display_login_button', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getScheduleTrimOverbooked()
|
||||||
|
{
|
||||||
|
return boolval(self::getValue('schedule_trim_overbooked', false));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function setScheduleTrimOverbooked($value)
|
||||||
|
{
|
||||||
|
self::setValue('schedule_trim_overbooked', $value);
|
||||||
|
}
|
||||||
|
|
||||||
public static function getRadioPageDisabled()
|
public static function getRadioPageDisabled()
|
||||||
{
|
{
|
||||||
return boolval(self::getValue('radio_page_disabled', false));
|
return boolval(self::getValue('radio_page_disabled', false));
|
||||||
|
|
|
@ -844,4 +844,33 @@ SQL;
|
||||||
{
|
{
|
||||||
return $this->getShow()->isRepeating();
|
return $this->getShow()->isRepeating();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function trimOverbooked()
|
||||||
|
{
|
||||||
|
// Remove all scheduled items that start time after the show has ended
|
||||||
|
$sql = <<<'SQL'
|
||||||
|
delete
|
||||||
|
from
|
||||||
|
cc_schedule
|
||||||
|
where
|
||||||
|
id in (
|
||||||
|
select
|
||||||
|
s.id
|
||||||
|
from
|
||||||
|
cc_schedule s
|
||||||
|
left join cc_show_instances si on
|
||||||
|
s.instance_id = si.id
|
||||||
|
where
|
||||||
|
si.id = :instance_id
|
||||||
|
and si.ends < s.starts
|
||||||
|
and s.playout_status = 0 -- playout_status = 0 double check that si.ends < s.starts
|
||||||
|
);
|
||||||
|
SQL;
|
||||||
|
|
||||||
|
return Application_Common_Database::prepareAndExecute(
|
||||||
|
$sql,
|
||||||
|
[':instance_id' => $this->_instanceId],
|
||||||
|
'execute'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,9 @@
|
||||||
|
|
||||||
<?php echo $this->element->getElement('thirdPartyApi')->render() ?>
|
<?php echo $this->element->getElement('thirdPartyApi')->render() ?>
|
||||||
|
|
||||||
|
<?php echo $this->element->getElement('scheduleTrimOverbooked')->renderViewHelper() ?>
|
||||||
|
<?php echo $this->element->getElement('scheduleTrimOverbooked')->renderLabel() ?>
|
||||||
|
<br/>
|
||||||
<?php echo $this->element->getElement('radioPageLoginButton')->renderViewHelper() ?>
|
<?php echo $this->element->getElement('radioPageLoginButton')->renderViewHelper() ?>
|
||||||
<?php echo $this->element->getElement('radioPageLoginButton')->renderLabel() ?>
|
<?php echo $this->element->getElement('radioPageLoginButton')->renderLabel() ?>
|
||||||
<br />
|
<br />
|
||||||
|
|
Loading…
Reference in New Issue