query type in debug panel

This commit is contained in:
evgen-d 2014-08-12 12:54:30 +04:00
parent 9c044353d0
commit 6f9bbda9f0
3 changed files with 30 additions and 2 deletions

View File

@ -122,6 +122,7 @@ class ArangoDbPanel extends Panel
foreach ($timings as $seq => $dbTiming) {
$this->_models[] = [
'type' => $this->getQueryType($dbTiming['category']),
'query' => $dbTiming['info'],
'duration' => ($dbTiming['duration'] * 1000), // in milliseconds
'trace' => $dbTiming['trace'],
@ -134,6 +135,23 @@ class ArangoDbPanel extends Panel
return $this->_models;
}
protected function getQueryType($category) {
switch ($category) {
case 'devgroup\arangodb\Query::query' :
return 'SELECT';
case 'devgroup\arangodb\Query::insert' :
return 'INSERT';
case 'devgroup\arangodb\Query::update' :
return 'UPDATE';
case 'devgroup\arangodb\Query::remove' :
return 'REMOVE';
case 'devgroup\arangodb\Query::execute' :
return 'EXECUTE';
default :
return '';
}
}
public function save()
{
return ['arango-messages' => $this->getProfileLogs()];

View File

@ -14,6 +14,8 @@ class ArangoDb extends Base
*/
public $query;
public $type;
/**
* @inheritdoc
@ -21,7 +23,7 @@ class ArangoDb extends Base
public function rules()
{
return [
[['query'], 'safe'],
[['query', 'type'], 'safe'],
];
}
@ -31,6 +33,7 @@ class ArangoDb extends Base
public function attributeLabels()
{
return [
'type' => 'Type',
'query' => 'Query',
];
}
@ -48,7 +51,7 @@ class ArangoDb extends Base
'allModels' => $models,
'pagination' => false,
'sort' => [
'attributes' => ['duration', 'seq', 'query'],
'attributes' => ['duration', 'seq', 'query', 'type'],
'defaultOrder' => [
'duration' => SORT_DESC,
],
@ -60,6 +63,7 @@ class ArangoDb extends Base
}
$filter = new Filter();
$this->addCondition($filter, 'type', true);
$this->addCondition($filter, 'query', true);
$dataProvider->allModels = $filter->filter($models);

View File

@ -44,6 +44,12 @@ echo GridView::widget([
'class' => 'sort-numerical'
]
],
[
'attribute' => 'type',
'value' => function ($data) {
return Html::encode(mb_strtoupper($data['type'], 'utf8'));
},
],
[
'attribute' => 'query',
'value' => function ($data) {