refactoring

This commit is contained in:
Ilya Rumyancev (MacBook) 2017-04-14 00:44:05 +03:00
parent a3a51c9c10
commit 9f02264965
13 changed files with 70 additions and 80 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
namespace devgroup\arangodb; namespace explosivebit\arangodb;
use Yii; use Yii;
use yii\db\ActiveQueryInterface; use yii\db\ActiveQueryInterface;
@ -104,14 +104,14 @@ class ActiveQuery extends Query implements ActiveQueryInterface
{ {
$statement = $this->createCommand($db); $statement = $this->createCommand($db);
$token = $this->getRawAql($statement); $token = $this->getRawAql($statement);
Yii::info($token, 'devgroup\arangodb\Query::query'); Yii::info($token, 'explosivebit\arangodb\Query::query');
try { try {
Yii::beginProfile($token, 'devgroup\arangodb\Query::query'); Yii::beginProfile($token, 'explosivebit\arangodb\Query::query');
$cursor = $statement->execute(); $cursor = $statement->execute();
$rows = $cursor->getAll(); $rows = $cursor->getAll();
Yii::endProfile($token, 'devgroup\arangodb\Query::query'); Yii::endProfile($token, 'explosivebit\arangodb\Query::query');
} catch (\Exception $ex) { } catch (\Exception $ex) {
Yii::endProfile($token, 'devgroup\arangodb\Query::query'); Yii::endProfile($token, 'explosivebit\arangodb\Query::query');
throw new \Exception($ex->getMessage(), (int) $ex->getCode(), $ex); throw new \Exception($ex->getMessage(), (int) $ex->getCode(), $ex);
} }
if (!empty($rows)) { if (!empty($rows)) {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace devgroup\arangodb; namespace explosivebit\arangodb;
use Yii; use Yii;
use yii\base\InvalidConfigException; use yii\base\InvalidConfigException;

View File

@ -5,7 +5,7 @@
* Time: 16:00 * Time: 16:00
*/ */
namespace devgroup\arangodb; namespace explosivebit\arangodb;
use yii\base\Object; use yii\base\Object;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace devgroup\arangodb; namespace explosivebit\arangodb;
use Yii; use Yii;
use triagens\ArangoDb\CollectionHandler; use triagens\ArangoDb\CollectionHandler;
@ -49,14 +49,14 @@ class Connection extends Object
$token = 'Opening ArangoDB connection: ' . $this->connectionOptions[ConnectionOptions::OPTION_ENDPOINT]; $token = 'Opening ArangoDB connection: ' . $this->connectionOptions[ConnectionOptions::OPTION_ENDPOINT];
try { try {
Yii::info($token, 'devgroup\arangodb\Connection::open'); Yii::info($token, 'explosivebit\arangodb\Connection::open');
Yii::beginProfile($token, 'devgroup\arangodb\Connection::open'); Yii::beginProfile($token, 'explosivebit\arangodb\Connection::open');
$this->connection = new \triagens\ArangoDb\Connection($this->connectionOptions); $this->connection = new \triagens\ArangoDb\Connection($this->connectionOptions);
$this->collectionHandler = new CollectionHandler($this->connection); $this->collectionHandler = new CollectionHandler($this->connection);
$this->documentHandler = new DocumentHandler($this->connection); $this->documentHandler = new DocumentHandler($this->connection);
Yii::endProfile($token, 'devgroup\arangodb\Connection::open'); Yii::endProfile($token, 'explosivebit\arangodb\Connection::open');
} catch (\Exception $ex) { } catch (\Exception $ex) {
Yii::endProfile($token, 'devgroup\arangodb\Connection::open'); Yii::endProfile($token, 'explosivebit\arangodb\Connection::open');
throw new \Exception($ex->getMessage(), (int) $ex->getCode(), $ex); throw new \Exception($ex->getMessage(), (int) $ex->getCode(), $ex);
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace devgroup\arangodb; namespace explosivebit\arangodb;
class Exception extends \yii\base\Exception class Exception extends \yii\base\Exception
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
namespace devgroup\arangodb; namespace explosivebit\arangodb;
use yii\base\Component; use yii\base\Component;
use yii\db\MigrationInterface; use yii\db\MigrationInterface;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace devgroup\arangodb; namespace explosivebit\arangodb;
use Yii; use Yii;
use triagens\ArangoDb\Document; use triagens\ArangoDb\Document;
@ -131,13 +131,13 @@ class Query extends Component implements QueryInterface
$options = ArrayHelper::merge($params, $options); $options = ArrayHelper::merge($params, $options);
$statement = $this->getStatement($options); $statement = $this->getStatement($options);
$token = $this->getRawAql($statement); $token = $this->getRawAql($statement);
Yii::info($token, 'devgroup\arangodb\Query::query'); Yii::info($token, 'explosivebit\arangodb\Query::query');
try { try {
Yii::beginProfile($token, 'devgroup\arangodb\Query::query'); Yii::beginProfile($token, 'explosivebit\arangodb\Query::query');
$cursor = $statement->execute(); $cursor = $statement->execute();
Yii::endProfile($token, 'devgroup\arangodb\Query::query'); Yii::endProfile($token, 'explosivebit\arangodb\Query::query');
} catch (\Exception $ex) { } catch (\Exception $ex) {
Yii::endProfile($token, 'devgroup\arangodb\Query::query'); Yii::endProfile($token, 'explosivebit\arangodb\Query::query');
throw new \Exception($ex->getMessage(), (int) $ex->getCode(), $ex); throw new \Exception($ex->getMessage(), (int) $ex->getCode(), $ex);
} }
return $this->prepareResult($cursor->getAll()); return $this->prepareResult($cursor->getAll());
@ -619,13 +619,13 @@ class Query extends Component implements QueryInterface
{ {
$statement = $this->createCommand($db); $statement = $this->createCommand($db);
$token = $this->getRawAql($statement); $token = $this->getRawAql($statement);
Yii::info($token, 'devgroup\arangodb\Query::query'); Yii::info($token, 'explosivebit\arangodb\Query::query');
try { try {
Yii::beginProfile($token, 'devgroup\arangodb\Query::query'); Yii::beginProfile($token, 'explosivebit\arangodb\Query::query');
$cursor = $statement->execute(); $cursor = $statement->execute();
Yii::endProfile($token, 'devgroup\arangodb\Query::query'); Yii::endProfile($token, 'explosivebit\arangodb\Query::query');
} catch (\Exception $ex) { } catch (\Exception $ex) {
Yii::endProfile($token, 'devgroup\arangodb\Query::query'); Yii::endProfile($token, 'explosivebit\arangodb\Query::query');
throw new \Exception($ex->getMessage(), (int) $ex->getCode(), $ex); throw new \Exception($ex->getMessage(), (int) $ex->getCode(), $ex);
} }
return $this->prepareResult($cursor->getAll()); return $this->prepareResult($cursor->getAll());
@ -641,13 +641,13 @@ class Query extends Component implements QueryInterface
$this->limit(1); $this->limit(1);
$statement = $this->createCommand($db); $statement = $this->createCommand($db);
$token = $this->getRawAql($statement); $token = $this->getRawAql($statement);
Yii::info($token, 'devgroup\arangodb\Query::query'); Yii::info($token, 'explosivebit\arangodb\Query::query');
try { try {
Yii::beginProfile($token, 'devgroup\arangodb\Query::query'); Yii::beginProfile($token, 'explosivebit\arangodb\Query::query');
$cursor = $statement->execute(); $cursor = $statement->execute();
Yii::endProfile($token, 'devgroup\arangodb\Query::query'); Yii::endProfile($token, 'explosivebit\arangodb\Query::query');
} catch (\Exception $ex) { } catch (\Exception $ex) {
Yii::endProfile($token, 'devgroup\arangodb\Query::query'); Yii::endProfile($token, 'explosivebit\arangodb\Query::query');
throw new \Exception($ex->getMessage(), (int) $ex->getCode(), $ex); throw new \Exception($ex->getMessage(), (int) $ex->getCode(), $ex);
} }
$result = $this->prepareResult($cursor->getAll()); $result = $this->prepareResult($cursor->getAll());
@ -682,13 +682,13 @@ class Query extends Component implements QueryInterface
$statement = $this->getStatement($params, $db); $statement = $this->getStatement($params, $db);
$token = $this->getRawAql($statement); $token = $this->getRawAql($statement);
Yii::info($token, 'devgroup\arangodb\Query::insert'); Yii::info($token, 'explosivebit\arangodb\Query::insert');
try { try {
Yii::beginProfile($token, 'devgroup\arangodb\Query::insert'); Yii::beginProfile($token, 'explosivebit\arangodb\Query::insert');
$cursor = $statement->execute(); $cursor = $statement->execute();
Yii::endProfile($token, 'devgroup\arangodb\Query::insert'); Yii::endProfile($token, 'explosivebit\arangodb\Query::insert');
} catch (\Exception $ex) { } catch (\Exception $ex) {
Yii::endProfile($token, 'devgroup\arangodb\Query::insert'); Yii::endProfile($token, 'explosivebit\arangodb\Query::insert');
throw new \Exception($ex->getMessage(), (int) $ex->getCode(), $ex); throw new \Exception($ex->getMessage(), (int) $ex->getCode(), $ex);
} }
return true; return true;
@ -725,13 +725,13 @@ class Query extends Component implements QueryInterface
$statement = $this->getStatement($params, $db); $statement = $this->getStatement($params, $db);
$token = $this->getRawAql($statement); $token = $this->getRawAql($statement);
Yii::info($token, 'devgroup\arangodb\Query::update'); Yii::info($token, 'explosivebit\arangodb\Query::update');
try { try {
Yii::beginProfile($token, 'devgroup\arangodb\Query::update'); Yii::beginProfile($token, 'explosivebit\arangodb\Query::update');
$cursor = $statement->execute(); $cursor = $statement->execute();
Yii::endProfile($token, 'devgroup\arangodb\Query::update'); Yii::endProfile($token, 'explosivebit\arangodb\Query::update');
} catch (\Exception $ex) { } catch (\Exception $ex) {
Yii::endProfile($token, 'devgroup\arangodb\Query::update'); Yii::endProfile($token, 'explosivebit\arangodb\Query::update');
throw new \Exception($ex->getMessage(), (int) $ex->getCode(), $ex); throw new \Exception($ex->getMessage(), (int) $ex->getCode(), $ex);
} }
$meta = $cursor->getMetadata(); $meta = $cursor->getMetadata();
@ -770,13 +770,13 @@ class Query extends Component implements QueryInterface
$statement = $this->getStatement($params, $db); $statement = $this->getStatement($params, $db);
$token = $this->getRawAql($statement); $token = $this->getRawAql($statement);
Yii::info($token, 'devgroup\arangodb\Query::remove'); Yii::info($token, 'explosivebit\arangodb\Query::remove');
try { try {
Yii::beginProfile($token, 'devgroup\arangodb\Query::remove'); Yii::beginProfile($token, 'explosivebit\arangodb\Query::remove');
$cursor = $statement->execute(); $cursor = $statement->execute();
Yii::endProfile($token, 'devgroup\arangodb\Query::remove'); Yii::endProfile($token, 'explosivebit\arangodb\Query::remove');
} catch (\Exception $ex) { } catch (\Exception $ex) {
Yii::endProfile($token, 'devgroup\arangodb\Query::remove'); Yii::endProfile($token, 'explosivebit\arangodb\Query::remove');
throw new \Exception($ex->getMessage(), (int) $ex->getCode(), $ex); throw new \Exception($ex->getMessage(), (int) $ex->getCode(), $ex);
} }
$meta = $cursor->getMetadata(); $meta = $cursor->getMetadata();
@ -859,13 +859,13 @@ class Query extends Component implements QueryInterface
$statement->setBatchSize(1); $statement->setBatchSize(1);
$token = $this->getRawAql($statement); $token = $this->getRawAql($statement);
Yii::info($token, 'devgroup\arangodb\Query::query'); Yii::info($token, 'explosivebit\arangodb\Query::query');
try { try {
Yii::beginProfile($token, 'devgroup\arangodb\Query::query'); Yii::beginProfile($token, 'explosivebit\arangodb\Query::query');
$cursor = $statement->execute(); $cursor = $statement->execute();
Yii::endProfile($token, 'devgroup\arangodb\Query::query'); Yii::endProfile($token, 'explosivebit\arangodb\Query::query');
} catch (\Exception $ex) { } catch (\Exception $ex) {
Yii::endProfile($token, 'devgroup\arangodb\Query::query'); Yii::endProfile($token, 'explosivebit\arangodb\Query::query');
throw new \Exception($ex->getMessage(), (int) $ex->getCode(), $ex); throw new \Exception($ex->getMessage(), (int) $ex->getCode(), $ex);
} }
return $cursor->getFullCount(); return $cursor->getFullCount();

View File

@ -5,7 +5,7 @@
* Time: 16:04 * Time: 16:04
*/ */
namespace devgroup\arangodb; namespace explosivebit\arangodb;
use yii\base\Arrayable; use yii\base\Arrayable;

View File

@ -6,16 +6,8 @@
"license": "GPL-3.0+", "license": "GPL-3.0+",
"authors": [ "authors": [
{ {
"name": "Alexander Kozhevnikov", "name": "Ilya Rumyantsev",
"email": "b37hr3z3n@gmail.com" "email": "explosivebit@gmail.com"
},
{
"name": "Evgeny Dubovitsky",
"email": "flynn068@gmail.com"
},
{
"name": "Pavel Fedotov",
"email": "fps.06@mail.ru"
} }
], ],
"minimum-stability": "dev", "minimum-stability": "dev",
@ -28,7 +20,7 @@
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"devgroup\\arangodb\\": "" "explosivebit\\arangodb\\": ""
} }
} }
} }

View File

@ -1,11 +1,11 @@
<?php <?php
namespace devgroup\arangodb\console\controllers; namespace explosivebit\arangodb\console\controllers;
use devgroup\arangodb\Connection; use explosivebit\arangodb\Connection;
use devgroup\arangodb\Exception; use explosivebit\arangodb\Exception;
use devgroup\arangodb\Migration; use explosivebit\arangodb\Migration;
use devgroup\arangodb\Query; use explosivebit\arangodb\Query;
use yii; use yii;
use yii\console\controllers\BaseMigrateController; use yii\console\controllers\BaseMigrateController;
@ -25,7 +25,7 @@ class MigrateController extends BaseMigrateController
/** /**
* @inheritdoc * @inheritdoc
*/ */
public $templateFile = '@devgroup/arangodb/views/migration.php'; public $templateFile = '@explosivebit/arangodb/views/migration.php';
/** /**
* @var Connection|string the DB connection object or the application * @var Connection|string the DB connection object or the application
* component ID of the DB connection. * component ID of the DB connection.

View File

@ -1,8 +1,8 @@
<?php <?php
namespace devgroup\arangodb\panels\arangodb; namespace explosivebit\arangodb\panels\arangodb;
use devgroup\arangodb\panels\arangodb\models\ArangoDb; use explosivebit\arangodb\panels\arangodb\models\ArangoDb;
use Yii; use Yii;
use yii\debug\Panel; use yii\debug\Panel;
use yii\log\Logger; use yii\log\Logger;
@ -31,11 +31,11 @@ class ArangoDbPanel extends Panel
$target->messages, $target->messages,
Logger::LEVEL_PROFILE, Logger::LEVEL_PROFILE,
[ [
'devgroup\arangodb\Query::query', 'explosivebit\arangodb\Query::query',
'devgroup\arangodb\Query::insert', 'explosivebit\arangodb\Query::insert',
'devgroup\arangodb\Query::update', 'explosivebit\arangodb\Query::update',
'devgroup\arangodb\Query::remove', 'explosivebit\arangodb\Query::remove',
'devgroup\arangodb\Query::execute', 'explosivebit\arangodb\Query::execute',
] ]
); );
} }
@ -83,7 +83,7 @@ class ArangoDbPanel extends Panel
$queryTime = number_format($this->getTotalQueryTime($timings) * 1000) . ' ms'; $queryTime = number_format($this->getTotalQueryTime($timings) * 1000) . ' ms';
return \Yii::$app->view->render( return \Yii::$app->view->render(
'@devgroup/arangodb/panels/arangodb/views/summary', '@explosivebit/arangodb/panels/arangodb/views/summary',
[ [
'timings' => $this->calculateTimings(), 'timings' => $this->calculateTimings(),
'queryCount' => $queryCount, 'queryCount' => $queryCount,
@ -101,7 +101,7 @@ class ArangoDbPanel extends Panel
$searchModel = new ArangoDb(); $searchModel = new ArangoDb();
$dataProvider = $searchModel->search(Yii::$app->request->getQueryParams(), $this->getModels()); $dataProvider = $searchModel->search(Yii::$app->request->getQueryParams(), $this->getModels());
return Yii::$app->view->render('@devgroup/arangodb/panels/arangodb/views/detail', [ return Yii::$app->view->render('@explosivebit/arangodb/panels/arangodb/views/detail', [
'panel' => $this, 'panel' => $this,
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
'searchModel' => $searchModel, 'searchModel' => $searchModel,
@ -136,15 +136,15 @@ class ArangoDbPanel extends Panel
protected function getQueryType($category) { protected function getQueryType($category) {
switch ($category) { switch ($category) {
case 'devgroup\arangodb\Query::query' : case 'explosivebit\arangodb\Query::query' :
return 'SELECT'; return 'SELECT';
case 'devgroup\arangodb\Query::insert' : case 'explosivebit\arangodb\Query::insert' :
return 'INSERT'; return 'INSERT';
case 'devgroup\arangodb\Query::update' : case 'explosivebit\arangodb\Query::update' :
return 'UPDATE'; return 'UPDATE';
case 'devgroup\arangodb\Query::remove' : case 'explosivebit\arangodb\Query::remove' :
return 'REMOVE'; return 'REMOVE';
case 'devgroup\arangodb\Query::execute' : case 'explosivebit\arangodb\Query::execute' :
return 'EXECUTE'; return 'EXECUTE';
default : default :
return ''; return '';

View File

@ -1,6 +1,6 @@
<?php <?php
namespace devgroup\arangodb\panels\arangodb\models; namespace explosivebit\arangodb\panels\arangodb\models;
use yii; use yii;
use yii\data\ArrayDataProvider; use yii\data\ArrayDataProvider;

View File

@ -12,13 +12,11 @@ class <?= $className ?> extends \devgroup\arangodb\Migration
{ {
public function up() public function up()
{ {
$this->createCollection('<?= $className ?>',[]);
} }
public function down() public function down()
{ {
echo "<?= $className ?> cannot be reverted.\n"; $this->dropCollection('<?= $className ?>');
return false;
} }
} }