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) { foreach ($timings as $seq => $dbTiming) {
$this->_models[] = [ $this->_models[] = [
'type' => $this->getQueryType($dbTiming['category']),
'query' => $dbTiming['info'], 'query' => $dbTiming['info'],
'duration' => ($dbTiming['duration'] * 1000), // in milliseconds 'duration' => ($dbTiming['duration'] * 1000), // in milliseconds
'trace' => $dbTiming['trace'], 'trace' => $dbTiming['trace'],
@ -134,6 +135,23 @@ class ArangoDbPanel extends Panel
return $this->_models; 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() public function save()
{ {
return ['arango-messages' => $this->getProfileLogs()]; return ['arango-messages' => $this->getProfileLogs()];

View File

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

View File

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