CC-4275: Enable debug mode where all Propel queries are displayed in raw SQL
-add enablePropelLogging and disablePropelLogging functions
This commit is contained in:
parent
7cbe037c7e
commit
9893282e43
airtime_mvc/application
|
@ -14,18 +14,6 @@ require_once __DIR__."/configs/ACL.php";
|
|||
require_once 'propel/runtime/lib/Propel.php';
|
||||
|
||||
Propel::init(__DIR__."/configs/airtime-conf-production.php");
|
||||
if (defined('APPLICATION_ENV') && APPLICATION_ENV == "development") {
|
||||
$logger = Logging::getLogger();
|
||||
Propel::setLogger($logger);
|
||||
|
||||
$con = Propel::getConnection();
|
||||
$con->useDebug(true);
|
||||
|
||||
$config = Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT);
|
||||
$config->setParameter('debugpdo.logging.details.method.enabled', true);
|
||||
$config->setParameter('debugpdo.logging.details.time.enabled', true);
|
||||
$config->setParameter('debugpdo.logging.details.mem.enabled', true);
|
||||
}
|
||||
|
||||
require_once __DIR__."/configs/constants.php";
|
||||
require_once 'Preference.php';
|
||||
|
|
|
@ -69,4 +69,26 @@ class Logging {
|
|||
$logger->debug("[$file : $function() : line $line] - ".self::toString($p_msg));
|
||||
}
|
||||
}
|
||||
|
||||
public static function enablePropelLogging()
|
||||
{
|
||||
$logger = Logging::getLogger();
|
||||
Propel::setLogger($logger);
|
||||
|
||||
$con = Propel::getConnection();
|
||||
$con->useDebug(true);
|
||||
|
||||
$config = Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT);
|
||||
$config->setParameter('debugpdo.logging.details.method.enabled', true);
|
||||
$config->setParameter('debugpdo.logging.details.time.enabled', true);
|
||||
$config->setParameter('debugpdo.logging.details.mem.enabled', true);
|
||||
}
|
||||
|
||||
public static function disablePropelLogging()
|
||||
{
|
||||
$con = Propel::getConnection();
|
||||
$con->useDebug(false);
|
||||
Propel::setLogger(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -262,21 +262,21 @@ EOT;
|
|||
return $length;
|
||||
}
|
||||
|
||||
public function getLength()
|
||||
public function getLength()
|
||||
{
|
||||
$this->block->reload();
|
||||
$prepend = "";
|
||||
if ($this->isStatic()){
|
||||
$length = $this->block->getDbLength();
|
||||
$prepend = "";
|
||||
if ($this->isStatic()){
|
||||
$length = $this->block->getDbLength();
|
||||
} else {
|
||||
$length = $this->getDynamicBlockLength();
|
||||
if (!$this->hasItemLimit()) {
|
||||
if (!$this->hasItemLimit()) {
|
||||
$prepend = "~";
|
||||
}
|
||||
}
|
||||
}
|
||||
$formatter = new LengthFormatter($length);
|
||||
$length = $prepend.$formatter->format();
|
||||
return $length;
|
||||
$length = $prepend.$formatter->format();
|
||||
return $length;
|
||||
}
|
||||
|
||||
public function getDynamicBlockLength()
|
||||
|
@ -294,14 +294,14 @@ EOT;
|
|||
}
|
||||
} else if ($modifier == "hours") {
|
||||
$mins = $value * 60;
|
||||
if ($mins >59) {
|
||||
$hour = intval($mins/60);
|
||||
$hour = str_pad($hour, 2, "0", STR_PAD_LEFT);
|
||||
$value = $mins%60;
|
||||
if ($mins >59) {
|
||||
$hour = intval($mins/60);
|
||||
$hour = str_pad($hour, 2, "0", STR_PAD_LEFT);
|
||||
$value = $mins%60;
|
||||
}
|
||||
}
|
||||
$hour = str_pad($hour, 2, "0", STR_PAD_LEFT);
|
||||
$value = str_pad($value, 2, "0", STR_PAD_LEFT);
|
||||
$hour = str_pad($hour, 2, "0", STR_PAD_LEFT);
|
||||
$value = str_pad($value, 2, "0", STR_PAD_LEFT);
|
||||
$length = $hour.":".$value.":00";
|
||||
}
|
||||
return $length;
|
||||
|
@ -309,9 +309,9 @@ EOT;
|
|||
|
||||
public function getLimitValueAndModifier()
|
||||
{
|
||||
$result = CcBlockcriteriaQuery::create()->filterByDbBlockId($this->id)
|
||||
->filterByDbCriteria('limit')->findOne();
|
||||
$modifier = $result->getDbModifier();
|
||||
$result = CcBlockcriteriaQuery::create()->filterByDbBlockId($this->id)
|
||||
->filterByDbCriteria('limit')->findOne();
|
||||
$modifier = $result->getDbModifier();
|
||||
$value = $result->getDbValue();
|
||||
return array($value, $modifier);
|
||||
}
|
||||
|
@ -949,8 +949,9 @@ EOT;
|
|||
CcBlockQuery::create()->findPk($this->id)->setDbType($p_blockType)->save();
|
||||
}
|
||||
|
||||
public function setLength($value){
|
||||
$this->block->setDbLength($value);
|
||||
public function setLength($value)
|
||||
{
|
||||
$this->block->setDbLength($value);
|
||||
$this->block->save($this->con);
|
||||
$this->updateBlockLengthInAllPlaylist();
|
||||
}
|
||||
|
@ -967,7 +968,7 @@ EOT;
|
|||
$blockType = $data['etc']['sp_type'] == 0 ? 'static':'dynamic';
|
||||
$this->saveType($blockType);
|
||||
$this->storeCriteriaIntoDb($data);
|
||||
//get number of files that meet the criteria
|
||||
//get number of files that meet the criteria
|
||||
$files = $this->getListofFilesMeetCriteria();
|
||||
// if the block is dynamic, put null to the length
|
||||
// as it cannot be calculated
|
||||
|
@ -998,7 +999,8 @@ EOT;
|
|||
}
|
||||
}
|
||||
|
||||
public function storeCriteriaIntoDb($p_criteriaData){
|
||||
public function storeCriteriaIntoDb($p_criteriaData)
|
||||
{
|
||||
// delete criteria under $p_blockId
|
||||
CcBlockcriteriaQuery::create()->findByDbBlockId($this->id)->delete();
|
||||
Logging::info($p_criteriaData);
|
||||
|
@ -1006,7 +1008,7 @@ EOT;
|
|||
if (isset($p_criteriaData['criteria'])) {
|
||||
$critKeys = array_keys($p_criteriaData['criteria']);
|
||||
for ($i = 0; $i < count($critKeys); $i++) {
|
||||
foreach( $p_criteriaData['criteria'][$critKeys[$i]] as $d){
|
||||
foreach ($p_criteriaData['criteria'][$critKeys[$i]] as $d) {
|
||||
$qry = new CcBlockcriteria();
|
||||
$qry->setDbCriteria($d['sp_criteria_field'])
|
||||
->setDbModifier($d['sp_criteria_modifier'])
|
||||
|
@ -1048,18 +1050,18 @@ EOT;
|
|||
|
||||
public function updateBlockLengthInAllPlaylist()
|
||||
{
|
||||
$blocks = CcPlaylistcontentsQuery::create()->filterByDbBlockId($this->id)->find();
|
||||
$blocks->getFirst();
|
||||
$iterator = $blocks->getIterator();
|
||||
$blocks = CcPlaylistcontentsQuery::create()->filterByDbBlockId($this->id)->find();
|
||||
$blocks->getFirst();
|
||||
$iterator = $blocks->getIterator();
|
||||
while ($iterator->valid()) {
|
||||
$length = $this->getUnformatedLength();
|
||||
if (!preg_match("/^[0-9]{2}:[0-9]{2}:[0-9]{2}/", $length)) {
|
||||
$iterator->current()->setDbClipLength(null);
|
||||
} else {
|
||||
} else {
|
||||
$iterator->current()->setDbClipLength($length);
|
||||
}
|
||||
$iterator->current()->save();
|
||||
$iterator->next();
|
||||
}
|
||||
$iterator->current()->save();
|
||||
$iterator->next();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1094,33 +1096,33 @@ EOT;
|
|||
|
||||
public function getCriteria()
|
||||
{
|
||||
$criteriaOptions = array(
|
||||
0 => "Select criteria",
|
||||
"album_title" => "Album",
|
||||
"bit_rate" => "Bit Rate",
|
||||
"bpm" => "Bpm",
|
||||
"comments" => "Comments",
|
||||
"composer" => "Composer",
|
||||
"conductor" => "Conductor",
|
||||
"artist_name" => "Creator",
|
||||
"disc_number" => "Disc Number",
|
||||
"genre" => "Genre",
|
||||
"isrc_number" => "ISRC",
|
||||
"label" => "Label",
|
||||
"language" => "Language",
|
||||
"mtime" => "Last Modified",
|
||||
"lptime" => "Last Played",
|
||||
"length" => "Length",
|
||||
"lyricist" => "Lyricist",
|
||||
"mood" => "Mood",
|
||||
"name" => "Name",
|
||||
"orchestra" => "Orchestra",
|
||||
"rating" => "Rating",
|
||||
"sample_rate" => "Sample Rate",
|
||||
"track_title" => "Title",
|
||||
"track_number" => "Track Number",
|
||||
"utime" => "Uploaded",
|
||||
"year" => "Year"
|
||||
$criteriaOptions = array(
|
||||
0 => "Select criteria",
|
||||
"album_title" => "Album",
|
||||
"bit_rate" => "Bit Rate",
|
||||
"bpm" => "Bpm",
|
||||
"comments" => "Comments",
|
||||
"composer" => "Composer",
|
||||
"conductor" => "Conductor",
|
||||
"artist_name" => "Creator",
|
||||
"disc_number" => "Disc Number",
|
||||
"genre" => "Genre",
|
||||
"isrc_number" => "ISRC",
|
||||
"label" => "Label",
|
||||
"language" => "Language",
|
||||
"mtime" => "Last Modified",
|
||||
"lptime" => "Last Played",
|
||||
"length" => "Length",
|
||||
"lyricist" => "Lyricist",
|
||||
"mood" => "Mood",
|
||||
"name" => "Name",
|
||||
"orchestra" => "Orchestra",
|
||||
"rating" => "Rating",
|
||||
"sample_rate" => "Sample Rate",
|
||||
"track_title" => "Title",
|
||||
"track_number" => "Track Number",
|
||||
"utime" => "Uploaded",
|
||||
"year" => "Year"
|
||||
);
|
||||
|
||||
// Load criteria from db
|
||||
|
@ -1160,7 +1162,7 @@ EOT;
|
|||
$spCriteriaModifier = $criteria['modifier'];
|
||||
|
||||
$column = CcFilesPeer::getTableMap()->getColumnByPhpName(self::$criteria2PeerMap[$spCriteria]);
|
||||
// if the column is timestamp, convert it into UTC
|
||||
// if the column is timestamp, convert it into UTC
|
||||
if ($column->getType() == PropelColumnTypes::TIMESTAMP) {
|
||||
$spCriteriaValue = Application_Common_DateHelper::ConvertToUtcDateTimeString($criteria['value']);
|
||||
/* Check if only a date was supplied and trim
|
||||
|
@ -1214,7 +1216,9 @@ EOT;
|
|||
$limits['time'] = 1440 * 60;
|
||||
$limits['items'] = $storedCrit['limit']['value'];
|
||||
} else {
|
||||
$limits['time'] = $storedCrit['limit']['modifier'] == "hours" ? intval(floatval($storedCrit['limit']['value']) * 60 * 60) : intval($storedCrit['limit']['value'] * 60);
|
||||
$limits['time'] = $storedCrit['limit']['modifier'] == "hours" ?
|
||||
intval(floatval($storedCrit['limit']['value']) * 60 * 60) :
|
||||
intval($storedCrit['limit']['value'] * 60);
|
||||
$limits['items'] = null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue