CC-4223: Smart playlists: BPM criteria should have numeric modifiers
-done
This commit is contained in:
parent
1dbdadef62
commit
ea621fd9dc
|
@ -1148,7 +1148,7 @@ EOT;
|
||||||
// e.g 192kps is stored as 192000
|
// e.g 192kps is stored as 192000
|
||||||
$spCriteriaValue = $criteria['value']*1000;
|
$spCriteriaValue = $criteria['value']*1000;
|
||||||
} else {
|
} else {
|
||||||
$spCriteriaValue = $criteria['value'];
|
$spCriteriaValue = addslashes($criteria['value']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($spCriteriaModifier == "starts with") {
|
if ($spCriteriaModifier == "starts with") {
|
||||||
|
@ -1158,15 +1158,15 @@ EOT;
|
||||||
} else if ($spCriteriaModifier == "contains" || $spCriteriaModifier == "does not contain") {
|
} else if ($spCriteriaModifier == "contains" || $spCriteriaModifier == "does not contain") {
|
||||||
$spCriteriaValue = "%$spCriteriaValue%";
|
$spCriteriaValue = "%$spCriteriaValue%";
|
||||||
} else if ($spCriteriaModifier == "is in the range") {
|
} else if ($spCriteriaModifier == "is in the range") {
|
||||||
$spCriteriaValue = "$spCriteria > '$spCriteriaValue' AND $spCriteria < '$criteria[extra]'";
|
$spCriteriaValue = "$spCriteria > '$spCriteriaValue' AND $spCriteria <= '$criteria[extra]'";
|
||||||
}
|
}
|
||||||
|
|
||||||
$spCriteriaModifier = self::$modifier2CriteriaMap[$spCriteriaModifier];
|
$spCriteriaModifier = self::$modifier2CriteriaMap[$spCriteriaModifier];
|
||||||
try{
|
try{
|
||||||
if ($i > 0) {
|
if ($i > 0) {
|
||||||
$qry->addOr($spCriteria, addslashes($spCriteriaValue), $spCriteriaModifier);
|
$qry->addOr($spCriteria, $spCriteriaValue, $spCriteriaModifier);
|
||||||
} else {
|
} else {
|
||||||
$qry->add($spCriteria, addslashes($spCriteriaValue), $spCriteriaModifier);
|
$qry->add($spCriteria, $spCriteriaValue, $spCriteriaModifier);
|
||||||
}
|
}
|
||||||
}catch (Exception $e){
|
}catch (Exception $e){
|
||||||
Logging::log($e);
|
Logging::log($e);
|
||||||
|
|
|
@ -634,7 +634,7 @@ class Application_Model_StoredFile
|
||||||
$streamSelect[] = "EXTRACT(YEAR FROM utime)::varchar AS ".$key;
|
$streamSelect[] = "EXTRACT(YEAR FROM utime)::varchar AS ".$key;
|
||||||
}
|
}
|
||||||
//need to cast certain data as ints for the union to search on.
|
//need to cast certain data as ints for the union to search on.
|
||||||
else if (in_array($key, array("track_number", "bit_rate", "sample_rate"))) {
|
else if (in_array($key, array("track_number", "bit_rate", "sample_rate", "bpm"))) {
|
||||||
$plSelect[] = "NULL::int AS ".$key;
|
$plSelect[] = "NULL::int AS ".$key;
|
||||||
$blSelect[] = "NULL::int AS ".$key;
|
$blSelect[] = "NULL::int AS ".$key;
|
||||||
$fileSelect[] = $key;
|
$fileSelect[] = $key;
|
||||||
|
|
|
@ -64,7 +64,7 @@ class CcFilesTableMap extends TableMap {
|
||||||
$this->addColumn('TRACK_NUMBER', 'DbTrackNumber', 'INTEGER', false, null, null);
|
$this->addColumn('TRACK_NUMBER', 'DbTrackNumber', 'INTEGER', false, null, null);
|
||||||
$this->addColumn('CHANNELS', 'DbChannels', 'INTEGER', false, null, null);
|
$this->addColumn('CHANNELS', 'DbChannels', 'INTEGER', false, null, null);
|
||||||
$this->addColumn('URL', 'DbUrl', 'VARCHAR', false, 1024, null);
|
$this->addColumn('URL', 'DbUrl', 'VARCHAR', false, 1024, null);
|
||||||
$this->addColumn('BPM', 'DbBpm', 'VARCHAR', false, 8, null);
|
$this->addColumn('BPM', 'DbBpm', 'INTEGER', false, null, null);
|
||||||
$this->addColumn('RATING', 'DbRating', 'VARCHAR', false, 8, null);
|
$this->addColumn('RATING', 'DbRating', 'VARCHAR', false, 8, null);
|
||||||
$this->addColumn('ENCODED_BY', 'DbEncodedBy', 'VARCHAR', false, 255, null);
|
$this->addColumn('ENCODED_BY', 'DbEncodedBy', 'VARCHAR', false, 255, null);
|
||||||
$this->addColumn('DISC_NUMBER', 'DbDiscNumber', 'VARCHAR', false, 8, null);
|
$this->addColumn('DISC_NUMBER', 'DbDiscNumber', 'VARCHAR', false, 8, null);
|
||||||
|
|
|
@ -189,7 +189,7 @@ abstract class BaseCcFiles extends BaseObject implements Persistent
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The value for the bpm field.
|
* The value for the bpm field.
|
||||||
* @var string
|
* @var int
|
||||||
*/
|
*/
|
||||||
protected $bpm;
|
protected $bpm;
|
||||||
|
|
||||||
|
@ -814,7 +814,7 @@ abstract class BaseCcFiles extends BaseObject implements Persistent
|
||||||
/**
|
/**
|
||||||
* Get the [bpm] column value.
|
* Get the [bpm] column value.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getDbBpm()
|
public function getDbBpm()
|
||||||
{
|
{
|
||||||
|
@ -1822,13 +1822,13 @@ abstract class BaseCcFiles extends BaseObject implements Persistent
|
||||||
/**
|
/**
|
||||||
* Set the value of [bpm] column.
|
* Set the value of [bpm] column.
|
||||||
*
|
*
|
||||||
* @param string $v new value
|
* @param int $v new value
|
||||||
* @return CcFiles The current object (for fluent API support)
|
* @return CcFiles The current object (for fluent API support)
|
||||||
*/
|
*/
|
||||||
public function setDbBpm($v)
|
public function setDbBpm($v)
|
||||||
{
|
{
|
||||||
if ($v !== null) {
|
if ($v !== null) {
|
||||||
$v = (string) $v;
|
$v = (int) $v;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->bpm !== $v) {
|
if ($this->bpm !== $v) {
|
||||||
|
@ -2678,7 +2678,7 @@ abstract class BaseCcFiles extends BaseObject implements Persistent
|
||||||
$this->track_number = ($row[$startcol + 23] !== null) ? (int) $row[$startcol + 23] : null;
|
$this->track_number = ($row[$startcol + 23] !== null) ? (int) $row[$startcol + 23] : null;
|
||||||
$this->channels = ($row[$startcol + 24] !== null) ? (int) $row[$startcol + 24] : null;
|
$this->channels = ($row[$startcol + 24] !== null) ? (int) $row[$startcol + 24] : null;
|
||||||
$this->url = ($row[$startcol + 25] !== null) ? (string) $row[$startcol + 25] : null;
|
$this->url = ($row[$startcol + 25] !== null) ? (string) $row[$startcol + 25] : null;
|
||||||
$this->bpm = ($row[$startcol + 26] !== null) ? (string) $row[$startcol + 26] : null;
|
$this->bpm = ($row[$startcol + 26] !== null) ? (int) $row[$startcol + 26] : null;
|
||||||
$this->rating = ($row[$startcol + 27] !== null) ? (string) $row[$startcol + 27] : null;
|
$this->rating = ($row[$startcol + 27] !== null) ? (string) $row[$startcol + 27] : null;
|
||||||
$this->encoded_by = ($row[$startcol + 28] !== null) ? (string) $row[$startcol + 28] : null;
|
$this->encoded_by = ($row[$startcol + 28] !== null) ? (string) $row[$startcol + 28] : null;
|
||||||
$this->disc_number = ($row[$startcol + 29] !== null) ? (string) $row[$startcol + 29] : null;
|
$this->disc_number = ($row[$startcol + 29] !== null) ? (string) $row[$startcol + 29] : null;
|
||||||
|
|
|
@ -191,7 +191,7 @@
|
||||||
* @method CcFiles findOneByDbTrackNumber(int $track_number) Return the first CcFiles filtered by the track_number column
|
* @method CcFiles findOneByDbTrackNumber(int $track_number) Return the first CcFiles filtered by the track_number column
|
||||||
* @method CcFiles findOneByDbChannels(int $channels) Return the first CcFiles filtered by the channels column
|
* @method CcFiles findOneByDbChannels(int $channels) Return the first CcFiles filtered by the channels column
|
||||||
* @method CcFiles findOneByDbUrl(string $url) Return the first CcFiles filtered by the url column
|
* @method CcFiles findOneByDbUrl(string $url) Return the first CcFiles filtered by the url column
|
||||||
* @method CcFiles findOneByDbBpm(string $bpm) Return the first CcFiles filtered by the bpm column
|
* @method CcFiles findOneByDbBpm(int $bpm) Return the first CcFiles filtered by the bpm column
|
||||||
* @method CcFiles findOneByDbRating(string $rating) Return the first CcFiles filtered by the rating column
|
* @method CcFiles findOneByDbRating(string $rating) Return the first CcFiles filtered by the rating column
|
||||||
* @method CcFiles findOneByDbEncodedBy(string $encoded_by) Return the first CcFiles filtered by the encoded_by column
|
* @method CcFiles findOneByDbEncodedBy(string $encoded_by) Return the first CcFiles filtered by the encoded_by column
|
||||||
* @method CcFiles findOneByDbDiscNumber(string $disc_number) Return the first CcFiles filtered by the disc_number column
|
* @method CcFiles findOneByDbDiscNumber(string $disc_number) Return the first CcFiles filtered by the disc_number column
|
||||||
|
@ -255,7 +255,7 @@
|
||||||
* @method array findByDbTrackNumber(int $track_number) Return CcFiles objects filtered by the track_number column
|
* @method array findByDbTrackNumber(int $track_number) Return CcFiles objects filtered by the track_number column
|
||||||
* @method array findByDbChannels(int $channels) Return CcFiles objects filtered by the channels column
|
* @method array findByDbChannels(int $channels) Return CcFiles objects filtered by the channels column
|
||||||
* @method array findByDbUrl(string $url) Return CcFiles objects filtered by the url column
|
* @method array findByDbUrl(string $url) Return CcFiles objects filtered by the url column
|
||||||
* @method array findByDbBpm(string $bpm) Return CcFiles objects filtered by the bpm column
|
* @method array findByDbBpm(int $bpm) Return CcFiles objects filtered by the bpm column
|
||||||
* @method array findByDbRating(string $rating) Return CcFiles objects filtered by the rating column
|
* @method array findByDbRating(string $rating) Return CcFiles objects filtered by the rating column
|
||||||
* @method array findByDbEncodedBy(string $encoded_by) Return CcFiles objects filtered by the encoded_by column
|
* @method array findByDbEncodedBy(string $encoded_by) Return CcFiles objects filtered by the encoded_by column
|
||||||
* @method array findByDbDiscNumber(string $disc_number) Return CcFiles objects filtered by the disc_number column
|
* @method array findByDbDiscNumber(string $disc_number) Return CcFiles objects filtered by the disc_number column
|
||||||
|
@ -1061,20 +1061,29 @@ abstract class BaseCcFilesQuery extends ModelCriteria
|
||||||
/**
|
/**
|
||||||
* Filter the query on the bpm column
|
* Filter the query on the bpm column
|
||||||
*
|
*
|
||||||
* @param string $dbBpm The value to use as filter.
|
* @param int|array $dbBpm The value to use as filter.
|
||||||
* Accepts wildcards (* and % trigger a LIKE)
|
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
|
||||||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||||
*
|
*
|
||||||
* @return CcFilesQuery The current query, for fluid interface
|
* @return CcFilesQuery The current query, for fluid interface
|
||||||
*/
|
*/
|
||||||
public function filterByDbBpm($dbBpm = null, $comparison = null)
|
public function filterByDbBpm($dbBpm = null, $comparison = null)
|
||||||
{
|
{
|
||||||
if (null === $comparison) {
|
if (is_array($dbBpm)) {
|
||||||
if (is_array($dbBpm)) {
|
$useMinMax = false;
|
||||||
|
if (isset($dbBpm['min'])) {
|
||||||
|
$this->addUsingAlias(CcFilesPeer::BPM, $dbBpm['min'], Criteria::GREATER_EQUAL);
|
||||||
|
$useMinMax = true;
|
||||||
|
}
|
||||||
|
if (isset($dbBpm['max'])) {
|
||||||
|
$this->addUsingAlias(CcFilesPeer::BPM, $dbBpm['max'], Criteria::LESS_EQUAL);
|
||||||
|
$useMinMax = true;
|
||||||
|
}
|
||||||
|
if ($useMinMax) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
if (null === $comparison) {
|
||||||
$comparison = Criteria::IN;
|
$comparison = Criteria::IN;
|
||||||
} elseif (preg_match('/[\%\*]/', $dbBpm)) {
|
|
||||||
$dbBpm = str_replace('*', '%', $dbBpm);
|
|
||||||
$comparison = Criteria::LIKE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->addUsingAlias(CcFilesPeer::BPM, $dbBpm, $comparison);
|
return $this->addUsingAlias(CcFilesPeer::BPM, $dbBpm, $comparison);
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
<column name="track_number" phpName="DbTrackNumber" type="INTEGER" required="false"/>
|
<column name="track_number" phpName="DbTrackNumber" type="INTEGER" required="false"/>
|
||||||
<column name="channels" phpName="DbChannels" type="INTEGER" required="false"/>
|
<column name="channels" phpName="DbChannels" type="INTEGER" required="false"/>
|
||||||
<column name="url" phpName="DbUrl" type="VARCHAR" size="1024" required="false"/>
|
<column name="url" phpName="DbUrl" type="VARCHAR" size="1024" required="false"/>
|
||||||
<column name="bpm" phpName="DbBpm" type="VARCHAR" size="8" required="false"/>
|
<column name="bpm" phpName="DbBpm" type="INTEGER" required="false"/>
|
||||||
<column name="rating" phpName="DbRating" type="VARCHAR" size="8" required="false"/>
|
<column name="rating" phpName="DbRating" type="VARCHAR" size="8" required="false"/>
|
||||||
<column name="encoded_by" phpName="DbEncodedBy" type="VARCHAR" size="255" required="false"/>
|
<column name="encoded_by" phpName="DbEncodedBy" type="VARCHAR" size="255" required="false"/>
|
||||||
<column name="disc_number" phpName="DbDiscNumber" type="VARCHAR" size="8" required="false"/>
|
<column name="disc_number" phpName="DbDiscNumber" type="VARCHAR" size="8" required="false"/>
|
||||||
|
|
|
@ -56,7 +56,7 @@ CREATE TABLE "cc_files"
|
||||||
"track_number" INTEGER,
|
"track_number" INTEGER,
|
||||||
"channels" INTEGER,
|
"channels" INTEGER,
|
||||||
"url" VARCHAR(1024),
|
"url" VARCHAR(1024),
|
||||||
"bpm" VARCHAR(8),
|
"bpm" INTEGER,
|
||||||
"rating" VARCHAR(8),
|
"rating" VARCHAR(8),
|
||||||
"encoded_by" VARCHAR(255),
|
"encoded_by" VARCHAR(255),
|
||||||
"disc_number" VARCHAR(8),
|
"disc_number" VARCHAR(8),
|
||||||
|
|
Loading…
Reference in New Issue