From 4d3c624607836ea4206aa52daad1f5b67b90c177 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 10 Sep 2012 12:35:32 -0400 Subject: [PATCH 1/9] CC-4380: Show ReplayGain value in the Library page - temp commit --- airtime_mvc/application/models/StoredFile.php | 2 +- .../models/airtime/map/CcFilesTableMap.php | 2 +- .../models/airtime/om/BaseCcFilesQuery.php | 23 +++++++++++++------ airtime_mvc/build/schema.xml | 2 +- airtime_mvc/build/sql/schema.sql | 4 ++-- .../public/js/airtime/library/library.js | 6 +++-- 6 files changed, 25 insertions(+), 14 deletions(-) diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 312208af8..53ded3e94 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -652,7 +652,7 @@ class Application_Model_StoredFile $displayColumns = array("id", "track_title", "artist_name", "album_title", "genre", "length", "year", "utime", "mtime", "ftype", "track_number", "mood", "bpm", "composer", "info_url", "bit_rate", "sample_rate", "isrc_number", "encoded_by", "label", "copyright", "mime", - "language", "filepath","owner","conductor" + "language", "filepath", "owner", "conductor", "replay_gain" ); //Logging::info($datatables); diff --git a/airtime_mvc/application/models/airtime/map/CcFilesTableMap.php b/airtime_mvc/application/models/airtime/map/CcFilesTableMap.php index 9c00c0b68..008c63007 100644 --- a/airtime_mvc/application/models/airtime/map/CcFilesTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcFilesTableMap.php @@ -100,7 +100,7 @@ class CcFilesTableMap extends TableMap { $this->addColumn('SOUNDCLOUD_ERROR_MSG', 'DbSoundcloudErrorMsg', 'VARCHAR', false, 512, null); $this->addColumn('SOUNDCLOUD_LINK_TO_FILE', 'DbSoundcloudLinkToFile', 'VARCHAR', false, 4096, null); $this->addColumn('SOUNDCLOUD_UPLOAD_TIME', 'DbSoundCloundUploadTime', 'TIMESTAMP', false, 6, null); - $this->addColumn('REPLAY_GAIN', 'DbReplayGain', 'VARCHAR', false, 16, null); + $this->addColumn('REPLAY_GAIN', 'DbReplayGain', 'NUMERIC', false, null, null); $this->addForeignKey('OWNER_ID', 'DbOwnerId', 'INTEGER', 'cc_subjs', 'ID', false, null, null); // validators } // initialize() diff --git a/airtime_mvc/application/models/airtime/om/BaseCcFilesQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcFilesQuery.php index 793bab857..0599719ac 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcFilesQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcFilesQuery.php @@ -1892,20 +1892,29 @@ abstract class BaseCcFilesQuery extends ModelCriteria /** * Filter the query on the replay_gain column * - * @param string $dbReplayGain The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) + * @param string|array $dbReplayGain The value to use as filter. + * Accepts an associative array('min' => $minValue, 'max' => $maxValue) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return CcFilesQuery The current query, for fluid interface */ public function filterByDbReplayGain($dbReplayGain = null, $comparison = null) { - if (null === $comparison) { - if (is_array($dbReplayGain)) { + if (is_array($dbReplayGain)) { + $useMinMax = false; + if (isset($dbReplayGain['min'])) { + $this->addUsingAlias(CcFilesPeer::REPLAY_GAIN, $dbReplayGain['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($dbReplayGain['max'])) { + $this->addUsingAlias(CcFilesPeer::REPLAY_GAIN, $dbReplayGain['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $dbReplayGain)) { - $dbReplayGain = str_replace('*', '%', $dbReplayGain); - $comparison = Criteria::LIKE; } } return $this->addUsingAlias(CcFilesPeer::REPLAY_GAIN, $dbReplayGain, $comparison); diff --git a/airtime_mvc/build/schema.xml b/airtime_mvc/build/schema.xml index b03e14011..b9899cca8 100644 --- a/airtime_mvc/build/schema.xml +++ b/airtime_mvc/build/schema.xml @@ -74,7 +74,7 @@ - + diff --git a/airtime_mvc/build/sql/schema.sql b/airtime_mvc/build/sql/schema.sql index 4fd4c1c45..cc47701c6 100644 --- a/airtime_mvc/build/sql/schema.sql +++ b/airtime_mvc/build/sql/schema.sql @@ -92,7 +92,7 @@ CREATE TABLE "cc_files" "soundcloud_error_msg" VARCHAR(512), "soundcloud_link_to_file" VARCHAR(4096), "soundcloud_upload_time" TIMESTAMP(6), - "replay_gain" VARCHAR(16), + "replay_gain" NUMERIC, "owner_id" INTEGER, PRIMARY KEY ("id") ); @@ -633,7 +633,7 @@ CREATE TABLE "cc_webstream" "id" serial NOT NULL, "name" VARCHAR(255) NOT NULL, "description" VARCHAR(255) NOT NULL, - "url" VARCHAR(255) NOT NULL, + "url" VARCHAR(512) NOT NULL, "length" interval default '00:00:00' NOT NULL, "creator_id" INTEGER NOT NULL, "mtime" TIMESTAMP(6) NOT NULL, diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js index b648c6acc..ba7c0f574 100644 --- a/airtime_mvc/public/js/airtime/library/library.js +++ b/airtime_mvc/public/js/airtime/library/library.js @@ -36,7 +36,8 @@ var AIRTIME = (function(AIRTIME) { "track_title" : "s", "track_num" : "n", "year" : "n", - "owner" : "s" + "owner" : "s", + "replay_gain" : "n" }; if (AIRTIME.library === undefined) { @@ -414,7 +415,8 @@ var AIRTIME = (function(AIRTIME) { /* Mime */ { "sTitle" : "Mime" , "mDataProp" : "mime" , "bVisible" : false , "sClass" : "library_mime" , "sWidth" : "80px" } , /* Language */ { "sTitle" : "Language" , "mDataProp" : "language" , "bVisible" : false , "sClass" : "library_language" , "sWidth" : "125px" } , /* Owner */ { "sTitle" : "Owner" , "mDataProp" : "owner" , "bVisible" : false , "sClass" : "library_language" , "sWidth" : "125px" } , - /* Conductor */ { "sTitle" : "Conductor" , "mDataProp" : "conductor" , "bVisible" : false , "sClass" : "library_conductor" , "sWidth" : "125px" } + /* Conductor */ { "sTitle" : "Conductor" , "mDataProp" : "conductor" , "bVisible" : false , "sClass" : "library_conductor" , "sWidth" : "125px" }, + /* Replay Gain */ { "sTitle" : "Replay Gain" , "mDataProp" : "replay_gain" , "bVisible" : false , "sClass" : "library_language" , "sWidth" : "125px" } ], "bProcessing": true, From 8d7a3a20425add875c697a6a65b0c51d0f21450d Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 10 Sep 2012 12:46:41 -0400 Subject: [PATCH 2/9] removed unused code --- python_apps/media-monitor2/media/monitor/manager.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/python_apps/media-monitor2/media/monitor/manager.py b/python_apps/media-monitor2/media/monitor/manager.py index fcceb153f..53599f3cb 100644 --- a/python_apps/media-monitor2/media/monitor/manager.py +++ b/python_apps/media-monitor2/media/monitor/manager.py @@ -28,8 +28,6 @@ class Manager(Loggable): include adding watched,store, organize directories, etc. Basically composes over WatchManager from pyinotify """ - global_inst = None - all_signals = set(['add_watch', 'remove_watch']) def __init__(self): self.wm = pyinotify.WatchManager() # These two instance variables are assumed to be constant @@ -66,7 +64,6 @@ class Manager(Loggable): # The following set isn't really necessary anymore. Should be # removed... self.watched_directories = set([]) - Manager.global_inst = self # This is the only event that we are unable to process "normally". I.e. # through dedicated handler objects. Because we must have access to a From e85a83d04551f36a48bbc22aadd64612c6c9b517 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 10 Sep 2012 14:14:44 -0400 Subject: [PATCH 3/9] Fixed pdo --- airtime_mvc/application/models/ShowInstance.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airtime_mvc/application/models/ShowInstance.php b/airtime_mvc/application/models/ShowInstance.php index a53bb3a8a..e6a3dcc58 100644 --- a/airtime_mvc/application/models/ShowInstance.php +++ b/airtime_mvc/application/models/ShowInstance.php @@ -816,7 +816,7 @@ SQL; $sql = << $day ), 'column' ); From 957e6448296ad29d387fb1045462ba07c43ca3b0 Mon Sep 17 00:00:00 2001 From: denise Date: Mon, 10 Sep 2012 14:16:36 -0400 Subject: [PATCH 4/9] -fixed javascript error in datatables.js --- airtime_mvc/application/models/Datatables.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/models/Datatables.php b/airtime_mvc/application/models/Datatables.php index 4a455fedd..60451972e 100644 --- a/airtime_mvc/application/models/Datatables.php +++ b/airtime_mvc/application/models/Datatables.php @@ -32,7 +32,9 @@ class Application_Model_Datatables } if (!empty($sub)) { $where['clause'][$dbname] = "(".implode(' AND ', $sub).")"; - $where['params'][$dbname."1"] = $input1; + if ($input1 != null) { + $where['params'][$dbname."1"] = $input1; + } if ($input2 != null) { $where['params'][$dbname."2"] = $input2; } @@ -44,7 +46,6 @@ class Application_Model_Datatables } } } - return $where; } /* From 0ab08af48f05ed21806056c087cdbc14e21eb74f Mon Sep 17 00:00:00 2001 From: James Date: Mon, 10 Sep 2012 14:37:38 -0400 Subject: [PATCH 5/9] CC-4380: Show ReplayGain value in the Library page - done --- airtime_mvc/application/models/Datatables.php | 2 +- airtime_mvc/application/models/StoredFile.php | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/airtime_mvc/application/models/Datatables.php b/airtime_mvc/application/models/Datatables.php index 60451972e..67586b3b3 100644 --- a/airtime_mvc/application/models/Datatables.php +++ b/airtime_mvc/application/models/Datatables.php @@ -118,7 +118,7 @@ class Application_Model_Datatables foreach ($searchCols as $col) { $simpleWhere['clause']["simple_".$col] = "{$col}::text ILIKE :simple_".$col; - $simpleWhere['params']["simple_".$col] = "%".$term."%"; + $simpleWhere['params']["simple_".$col] = "%".$term."%"; } $outerCond[] = "(".implode(" OR ", $simpleWhere['clause']).")"; } diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 53ded3e94..4d62bccb6 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -688,6 +688,11 @@ class Application_Model_StoredFile $blSelect[] = "login AS ".$key; $fileSelect[] = "sub.login AS $key"; $streamSelect[] = "login AS ".$key; + } elseif ($key === "replay_gain") { + $plSelect[] = "NULL::NUMERIC AS ".$key; + $blSelect[] = "NULL::NUMERIC AS ".$key; + $fileSelect[] = "replay_gain AS $key"; + $streamSelect[] = "NULL::NUMERIC AS ".$key; } //same columns in each table. else if (in_array($key, array("length", "utime", "mtime"))) { From 259a3eb79204620505c6c21a9ca3602273eb9020 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 10 Sep 2012 14:51:29 -0400 Subject: [PATCH 6/9] cc-4359: normpath'd music dir before passing it to manager.py to remove watch --- python_apps/media-monitor2/media/monitor/airtime.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python_apps/media-monitor2/media/monitor/airtime.py b/python_apps/media-monitor2/media/monitor/airtime.py index eba1f76e4..208556f71 100644 --- a/python_apps/media-monitor2/media/monitor/airtime.py +++ b/python_apps/media-monitor2/media/monitor/airtime.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from kombu.messaging import Exchange, Queue, Consumer from kombu.connection import BrokerConnection +from os.path import normpath import json import os @@ -133,7 +134,7 @@ class AirtimeMessageReceiver(Loggable): def remove_watch(self, msg): self.logger.info("Removing watch from directory: '%s'" % msg['directory']) - self.manager.remove_watch_directory(msg['directory']) + self.manager.remove_watch_directory(normpath(msg['directory'])) def rescan_watch(self, msg): self.logger.info("Trying to rescan watched directory: '%s'" % From 987b65af28970d6cf39c4fd85d9c1ae729a46612 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 10 Sep 2012 14:53:26 -0400 Subject: [PATCH 7/9] cc-4347: Extra pdo work --- airtime_mvc/application/models/MusicDir.php | 29 +++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/airtime_mvc/application/models/MusicDir.php b/airtime_mvc/application/models/MusicDir.php index f8e950821..373ad35f1 100644 --- a/airtime_mvc/application/models/MusicDir.php +++ b/airtime_mvc/application/models/MusicDir.php @@ -79,16 +79,29 @@ class Application_Model_MusicDir $music_dir_id = $this->getId(); - $sql = "SELECT DISTINCT s.instance_id from cc_music_dirs as md " - ." LEFT JOIN cc_files as f on f.directory = md.id" - ." RIGHT JOIN cc_schedule as s on s.file_id = f.id WHERE md.id = $music_dir_id"; - - $show_instances = $con->query($sql)->fetchAll(); + $sql = << $music_dir_id ), 'all' ); // get all the files on this dir - $sql = "UPDATE cc_files SET file_exists = 'f' WHERE id IN (SELECT f.id FROM cc_music_dirs as md " - ." LEFT JOIN cc_files as f on f.directory = md.id WHERE md.id = $music_dir_id)"; - $affected = $con->exec($sql); + $sql = << $music_dir_id ), 'all'); // set RemovedFlag to true if ($userAddedWatchedDir) { From 2e0b29b14e29e1f5c176ae8fbc3cc0a09c27fe3f Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 10 Sep 2012 15:31:56 -0400 Subject: [PATCH 8/9] Removed unused code --- airtime_mvc/application/models/Schedule.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index f97b21325..925dcd54b 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -1122,12 +1122,6 @@ SQL; */ //$se = $show_end->format('Y-m-d H:i:s'); if ($update) { - $sql = "SELECT id, starts, ends FROM ".$CC_CONFIG["showInstances"]." - where (ends <= '{$show_end->format('Y-m-d H:i:s')}' - or starts <= '{$show_end->format('Y-m-d H:i:s')}') - and date(starts) >= (date('{$show_end->format('Y-m-d H:i:s')}') - INTERVAL '2 days') - and modified_instance = false and id != ".$instanceId. " order by ends"; - $stmt = $con->prepare("SELECT id, starts, ends FROM {$CC_CONFIG['showInstances']} where (ends <= :show_end1 or starts <= :show_end2) @@ -1141,13 +1135,6 @@ SQL; ':instanceId' => $instanceId )); } else { - // TODO : Remove raw sql later - $sql = "SELECT id, starts, ends FROM ".$CC_CONFIG["showInstances"]." - where (ends <= '{$show_end->format('Y-m-d H:i:s')}' - or starts <= '{$show_end->format('Y-m-d H:i:s')}') - and date(starts) >= (date('{$show_end->format('Y-m-d H:i:s')}') - INTERVAL '2 days') - and modified_instance = false order by ends"; - $stmt = $con->prepare("SELECT id, starts, ends FROM {$CC_CONFIG['showInstances']} where (ends <= :show_end1 or starts <= :show_end2) From 9d825a55b3bb017a027694212b33fa226d0e946a Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Mon, 10 Sep 2012 15:32:31 -0400 Subject: [PATCH 9/9] Crap comment removed --- airtime_mvc/application/models/Schedule.php | 1 - 1 file changed, 1 deletion(-) diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index 925dcd54b..76c0ad6af 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -1147,7 +1147,6 @@ SQL; ':show_end3' => $show_end->format('Y-m-d H:i:s') )); } - //$rows = $con->query($sql); $rows = $stmt->fetchAll(); foreach ($rows as $row) {