Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
e85ea5c683
|
@ -32,7 +32,9 @@ class Application_Model_Datatables
|
|||
}
|
||||
if (!empty($sub)) {
|
||||
$where['clause'][$dbname] = "(".implode(' AND ', $sub).")";
|
||||
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;
|
||||
}
|
||||
/*
|
||||
|
|
|
@ -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 = <<<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 = :musicDirId;
|
||||
SQL;
|
||||
$show_instances = Application_Common_Database::prepareAndExecute($sql,
|
||||
array( ':musicDirId' => $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 = <<<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 = :musicDirId);
|
||||
SQL;
|
||||
|
||||
$affected = Application_Common_Database::prepareAndExecute($sql,
|
||||
array( ':musicDirId' => $music_dir_id ), 'all');
|
||||
|
||||
// set RemovedFlag to true
|
||||
if ($userAddedWatchedDir) {
|
||||
|
|
|
@ -1117,12 +1117,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)
|
||||
|
@ -1136,13 +1130,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)
|
||||
|
@ -1155,7 +1142,6 @@ SQL;
|
|||
':show_end3' => $show_end->format('Y-m-d H:i:s')
|
||||
));
|
||||
}
|
||||
//$rows = $con->query($sql);
|
||||
$rows = $stmt->fetchAll();
|
||||
|
||||
foreach ($rows as $row) {
|
||||
|
|
|
@ -816,7 +816,7 @@ SQL;
|
|||
$sql = <<<SQL
|
||||
SELECT count(*) AS cnt
|
||||
FROM cc_show_instances
|
||||
WHERE ends < '$day'
|
||||
WHERE ends < :day
|
||||
SQL;
|
||||
return Application_Common_Database::prepareAndExecute( $sql,
|
||||
array( ':day' => $day ), 'column' );
|
||||
|
|
|
@ -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);
|
||||
|
@ -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"))) {
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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)) {
|
||||
$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);
|
||||
|
|
|
@ -74,7 +74,7 @@
|
|||
<column name="soundcloud_error_msg" phpName="DbSoundcloudErrorMsg" type="VARCHAR" size="512" required="false"/>
|
||||
<column name="soundcloud_link_to_file" phpName="DbSoundcloudLinkToFile" type="VARCHAR" size="4096" required="false"/>
|
||||
<column name="soundcloud_upload_time" phpName="DbSoundCloundUploadTime" type="TIMESTAMP" size="6" required="false"/>
|
||||
<column name="replay_gain" phpName="DbReplayGain" type="VARCHAR" size="16" required="false"/>
|
||||
<column name="replay_gain" phpName="DbReplayGain" type="NUMERIC" required="false"/>
|
||||
<column name="owner_id" phpName="DbOwnerId" type="INTEGER" required="false"/>
|
||||
<foreign-key foreignTable="cc_subjs" phpName="FkOwner" name="cc_files_owner_fkey">
|
||||
<reference local="owner_id" foreign="id"/>
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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'" %
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue