From 8f31dd3069424dfd6701a9e62492a35b7341f8a9 Mon Sep 17 00:00:00 2001 From: Naomi Date: Fri, 10 May 2013 11:56:20 -0400 Subject: [PATCH 1/4] CC-5112 : Listen Status: Please clean obsoleted mount point from status report page --- .../application/models/ListenerStat.php | 20 ++++++++++++++++++- .../application/models/StreamSetting.php | 18 ++++++++++++++--- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/airtime_mvc/application/models/ListenerStat.php b/airtime_mvc/application/models/ListenerStat.php index f5567fed5..f5af3a318 100644 --- a/airtime_mvc/application/models/ListenerStat.php +++ b/airtime_mvc/application/models/ListenerStat.php @@ -46,7 +46,25 @@ SQL; $out[$r['mount_name']][] = $r; } } - return $out; + + $enabledStreamIds = Application_Model_StreamSetting::getEnabledStreamIds(); + $enabledOut = array(); + + foreach ($enabledStreamIds as $sId) { + + $sql = "SELECT value FROM cc_stream_setting" + ." WHERE keyname = :key"; + + $result = Application_Common_Database::prepareAndExecute($sql, array('key' => $sId."_mount"), "single"); + + $enabledMountPoint = $result["value"]; + + if (isset($out[$enabledMountPoint])) { + $enabledOut[$enabledMountPoint] = $out[$enabledMountPoint]; + } + } + + return $enabledOut; } public static function insertDataPoints($p_dataPoints) { diff --git a/airtime_mvc/application/models/StreamSetting.php b/airtime_mvc/application/models/StreamSetting.php index 58c8fb496..20e07adbb 100644 --- a/airtime_mvc/application/models/StreamSetting.php +++ b/airtime_mvc/application/models/StreamSetting.php @@ -283,6 +283,7 @@ class Application_Model_StreamSetting $con = Propel::getConnection(); $update_time = Application_Model_Preference::GetStreamUpdateTimestemp(); + if ($boot_time == null || $boot_time > $update_time) { $keyname = "s".$stream_id."_liquidsoap_error"; $sql = "SELECT COUNT(*) FROM cc_stream_setting" @@ -310,7 +311,7 @@ class Application_Model_StreamSetting $stmt = $con->prepare($sql); $stmt->bindParam(':keyname', $keyname); $stmt->bindParam(':msg', $msg); - + if ($stmt->execute()) { //do nothing } else { @@ -466,8 +467,19 @@ class Application_Model_StreamSetting } public static function GetAllListenerStatErrors(){ - $sql = "SELECT * FROM cc_stream_setting WHERE keyname like :p1"; - return Application_Common_Database::prepareAndExecute($sql, array(':p1'=>'%_listener_stat_error')); + $sql = "SELECT * FROM cc_stream_setting WHERE keyname like :p1"; + $mounts = Application_Common_Database::prepareAndExecute($sql, array(':p1'=>'%_mount')); + + $mps = array(); + + foreach($mounts as $mount) { + $mps[] = "'" .$mount["value"] . "_listener_stat_error'"; + } + + $in = implode(",", $mps); + + $sql = "SELECT * FROM cc_stream_setting WHERE keyname IN ( $in )"; + return Application_Common_Database::prepareAndExecute($sql, array()); } public static function SetListenerStatError($key, $v) { From 5666b688a09f4f0f598e4a00b9c219866a946e51 Mon Sep 17 00:00:00 2001 From: Naomi Date: Fri, 10 May 2013 12:03:33 -0400 Subject: [PATCH 2/4] CC-5112 : Listen Status: Please clean obsoleted mount point from status report page CRLF --- airtime_mvc/application/models/ListenerStat.php | 2 +- airtime_mvc/application/models/StreamSetting.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/models/ListenerStat.php b/airtime_mvc/application/models/ListenerStat.php index f5af3a318..52360c55a 100644 --- a/airtime_mvc/application/models/ListenerStat.php +++ b/airtime_mvc/application/models/ListenerStat.php @@ -52,7 +52,7 @@ SQL; foreach ($enabledStreamIds as $sId) { - $sql = "SELECT value FROM cc_stream_setting" + $sql = "SELECT value FROM cc_stream_setting" ." WHERE keyname = :key"; $result = Application_Common_Database::prepareAndExecute($sql, array('key' => $sId."_mount"), "single"); diff --git a/airtime_mvc/application/models/StreamSetting.php b/airtime_mvc/application/models/StreamSetting.php index df493b21d..bbe811b48 100644 --- a/airtime_mvc/application/models/StreamSetting.php +++ b/airtime_mvc/application/models/StreamSetting.php @@ -468,7 +468,7 @@ class Application_Model_StreamSetting } public static function GetAllListenerStatErrors(){ - $sql = "SELECT * FROM cc_stream_setting WHERE keyname like :p1"; + $sql = "SELECT * FROM cc_stream_setting WHERE keyname like :p1"; $mounts = Application_Common_Database::prepareAndExecute($sql, array(':p1'=>'%_mount')); $mps = array(); From c36333ae0790440c47a682db955e88a487ab9b64 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Fri, 10 May 2013 12:37:25 -0400 Subject: [PATCH 3/4] code cleanup -user proper method for checking null -reduce line length to 80 chars --- airtime_mvc/application/models/MusicDir.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/models/MusicDir.php b/airtime_mvc/application/models/MusicDir.php index 117d06f40..08b2b2649 100644 --- a/airtime_mvc/application/models/MusicDir.php +++ b/airtime_mvc/application/models/MusicDir.php @@ -195,7 +195,7 @@ SQL; $exist_dir = self::getDirByPath($p_path); - if ($exist_dir == NULL) { + if (is_null($exist_dir)) { $temp_dir = new CcMusicDirs(); $dir = new Application_Model_MusicDir($temp_dir); } else { @@ -228,7 +228,12 @@ SQL; return array("code"=>1, "error"=>"$msg"); } catch (Exception $e) { return array("code"=>1, - "error"=>sprintf(_("%s is already set as the current storage dir or in the watched folders list"), $p_path)); + "error" => sprintf( + _("%s is already set as the current storage dir or in the". + " watched folders list"), + $p_path + ) + ); } } From 2250d89cbd11746f28feab6ad2f39556fa9b5343 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Fri, 10 May 2013 13:19:56 -0400 Subject: [PATCH 4/4] CC-5013: Re-Added watched folder wont update -fixed --- airtime_mvc/application/controllers/ApiController.php | 4 ++-- airtime_mvc/application/models/StoredFile.php | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index c7fbae673..ec35c64b8 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -632,7 +632,7 @@ class ApiController extends Zend_Controller_Action $all = $request->getParam('all'); $this->view->files = - Application_Model_StoredFile::listAllFiles($dir_id,$all); + Application_Model_StoredFile::listAllFiles($dir_id, $all); } public function listAllWatchedDirsAction() @@ -800,7 +800,7 @@ class ApiController extends Zend_Controller_Action $watchDir = Application_Model_MusicDir::getDirByPath($rd); // get all the files that is under $dirPath $files = Application_Model_StoredFile::listAllFiles( - $dir->getId(),$all=false, true); + $dir->getId(),$all=false); foreach ($files as $f) { // if the file is from this mount if (substr($f->getFilePath(), 0, strlen($rd)) === $rd) { diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 4cfc7cb94..5db22107c 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -1071,7 +1071,7 @@ SQL; * @param $dir_id - if this is not provided, it returns all files with full * path constructed. */ - public static function listAllFiles($dir_id=null, $all) + public static function listAllFiles($dir_id=null, $all=true) { $con = Propel::getConnection(); @@ -1081,10 +1081,6 @@ FROM CC_FILES AS f WHERE f.directory = :dir_id SQL; - # TODO : the option $all is deprecated now and is always true. - # refactor code where it's still being passed - $all = true; - if (!$all) { $sql .= " AND f.file_exists = 'TRUE'"; }