feat: move off_air_meta stream setting to pref table (#2023)

This commit is contained in:
Jonas L 2022-08-06 19:18:40 +02:00 committed by GitHub
parent e408237be1
commit 6c59ff588b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 59 additions and 15 deletions

View File

@ -0,0 +1,44 @@
# pylint: disable=invalid-name
from django.db import migrations
from ._migrations import legacy_migration_factory
UP = """
insert into cc_pref ("keystr", "valstr")
select
"keyname" as "keystr",
coalesce("value", 'LibreTime - offline') as "valstr"
from cc_stream_setting
where "keyname" = 'off_air_meta';
delete from cc_stream_setting
where "keyname" = 'off_air_meta';
"""
DOWN = """
insert into cc_stream_setting ("keyname", "value", "type")
select
"keystr" as "keyname",
coalesce("valstr", 'LibreTime - offline') as "value",
'string' as "type"
from cc_pref
where "keystr" = 'off_air_meta';
delete from cc_pref
where "keystr" = 'off_air_meta';
"""
class Migration(migrations.Migration):
dependencies = [
("legacy", "0036_3_0_0_alpha_13_10"),
]
operations = [
migrations.RunPython(
code=legacy_migration_factory(
target="3.0.0-alpha.14.1",
sql=UP,
)
)
]

View File

@ -1 +1 @@
LEGACY_SCHEMA_VERSION = "3.0.0-alpha.13.10"
LEGACY_SCHEMA_VERSION = "3.0.0-alpha.14.1"

View File

@ -8,6 +8,7 @@ INSERT INTO cc_live_log ("state", "start_time") VALUES ('S', now() at time zone
INSERT INTO cc_pref ("keystr", "valstr") VALUES ('import_timestamp', '0');
INSERT INTO cc_pref ("keystr", "valstr") VALUES ('timezone', 'UTC');
INSERT INTO cc_pref ("keystr", "valstr") VALUES ('default_stream_mount_point', 'main');
INSERT INTO cc_pref ("keystr", "valstr") VALUES ('off_air_meta', 'LibreTime - offline');
INSERT INTO cc_pref ("keystr", "valstr") VALUES ('enable_replay_gain', 1);
INSERT INTO cc_pref ("keystr", "valstr") VALUES ('locale', 'en_US');
INSERT INTO cc_pref ("keystr", "valstr") VALUES ('max_bitrate', '320');
@ -24,7 +25,6 @@ INSERT INTO cc_subjs ("login", "type", "pass") VALUES ('admin', 'A', md5('admin'
INSERT INTO cc_pref ("subjid", "keystr", "valstr") VALUES (1, 'user_locale', 'en_US');
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('icecast_vorbis_metadata', 'false', 'boolean');
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('off_air_meta', 'LibreTime - offline', 'string');
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('output_sound_device_type', 'ALSA', 'string');
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('output_sound_device', 'false', 'boolean');

View File

@ -292,7 +292,7 @@ class PreferenceController extends Zend_Controller_Action
Application_Model_StreamSetting::setDjLiveStreamPort($values['show_source_port']);
Application_Model_StreamSetting::setDjLiveStreamMountPoint($values['show_source_mount']);
Application_Model_StreamSetting::setOffAirMeta($values['offAirMeta']);
Application_Model_Preference::setOffAirMeta($values['offAirMeta']);
// store stream update timestamp
Application_Model_Preference::SetStreamUpdateTimestamp();

View File

@ -65,7 +65,7 @@ class Application_Form_StreamSetting extends Zend_Form
$offAirMeta = new Zend_Form_Element_Text('offAirMeta');
$offAirMeta->setLabel(_('Off Air Metadata'))
->setValue(Application_Model_StreamSetting::getOffAirMeta())
->setValue(Application_Model_Preference::getOffAirMeta())
->setDecorators(['ViewHelper']);
$this->addElement($offAirMeta);

View File

@ -350,6 +350,16 @@ class Application_Model_Preference
return self::getValue('stream_label_format');
}
public static function getOffAirMeta()
{
return self::getValue('off_air_meta');
}
public static function setOffAirMeta($offAirMeta)
{
self::setValue('off_air_meta', $offAirMeta);
}
public static function GetStationName()
{
return self::getValue('station_name');

View File

@ -207,7 +207,7 @@ class Application_Model_StreamSetting
$settings['master_live_stream_mp'] = self::getMasterLiveStreamMountPoint();
$settings['dj_live_stream_port'] = self::getDjLiveStreamPort();
$settings['dj_live_stream_mp'] = self::getDjLiveStreamMountPoint();
$settings['off_air_meta'] = self::getOffAirMeta();
$settings['off_air_meta'] = Application_Model_Preference::getOffAirMeta();
$settings['icecast_vorbis_metadata'] = self::getIcecastVorbisMetadata();
$settings['output_sound_device'] = self::getOutputSoundDevice();
$settings['output_sound_device_type'] = self::getOutputSoundDeviceType();
@ -507,16 +507,6 @@ class Application_Model_StreamSetting
self::setValue($stream . '_admin_pass', $v, 'string');
}
public static function getOffAirMeta()
{
return self::getValue('off_air_meta');
}
public static function setOffAirMeta($offAirMeta)
{
self::setValue('off_air_meta', $offAirMeta, 'string');
}
public static function GetAllListenerStatErrors()
{
$sql = 'SELECT * FROM cc_stream_setting WHERE keyname like :p1';