From 6f9bbda9f0441541b2c7254f7a1c3d6e061ae28c Mon Sep 17 00:00:00 2001 From: evgen-d Date: Tue, 12 Aug 2014 12:54:30 +0400 Subject: [PATCH] query type in debug panel --- panels/arangodb/ArangoDbPanel.php | 18 ++++++++++++++++++ panels/arangodb/models/ArangoDb.php | 8 ++++++-- panels/arangodb/views/detail.php | 6 ++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/panels/arangodb/ArangoDbPanel.php b/panels/arangodb/ArangoDbPanel.php index 8cd4a22..407b24e 100644 --- a/panels/arangodb/ArangoDbPanel.php +++ b/panels/arangodb/ArangoDbPanel.php @@ -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()]; diff --git a/panels/arangodb/models/ArangoDb.php b/panels/arangodb/models/ArangoDb.php index 7609189..8bb8606 100644 --- a/panels/arangodb/models/ArangoDb.php +++ b/panels/arangodb/models/ArangoDb.php @@ -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); diff --git a/panels/arangodb/views/detail.php b/panels/arangodb/views/detail.php index c70a83b..8076db4 100644 --- a/panels/arangodb/views/detail.php +++ b/panels/arangodb/views/detail.php @@ -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) {