Skip to content

Commit

Permalink
Merge pull request #31 from NetCommons3/speedup
Browse files Browse the repository at this point in the history
速度改善のための修正
  • Loading branch information
s-nakajima committed Jun 3, 2018
2 parents 6a49926 + 7572432 commit 6280440
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 44 deletions.
20 changes: 18 additions & 2 deletions Model/Behavior/TagBehavior.php
Expand Up @@ -208,7 +208,23 @@ public function afterDelete(Model $Model) {
*/
public function getTagByTagId($Model, $tagId) {
$Tag = $this->_getTagModel();
$tag = $Tag->findById($tagId);
$tag = $Tag->find('first', [
'recursive' => -1,
'fields' => [
'Tag.id',
'Tag.block_id',
'Tag.model',
'Tag.key',
'Tag.language_id',
'Tag.is_origin',
'Tag.is_translation',
'Tag.is_original_copy',
'Tag.name',
],
'conditions' => [
'id' => $tagId
]
]);
return $tag;
}
}
}
15 changes: 15 additions & 0 deletions Model/Tag.php
Expand Up @@ -106,6 +106,21 @@ public function getTagsByContentId($modelName, $contentId) {
'TagsContent.content_id' => $contentId,
);
$options = array(
'fields' => [
'Tag.id',
'Tag.block_id',
'Tag.model',
'Tag.key',
'Tag.language_id',
'Tag.is_origin',
'Tag.is_translation',
'Tag.is_original_copy',
'Tag.name',
'TagsContent.id',
'TagsContent.model',
'TagsContent.content_id',
'TagsContent.tag_id',
],
'conditions' => $conditions,
);
$options['joins'] = array(
Expand Down
33 changes: 11 additions & 22 deletions Test/Fixture/TagFixture.php
Expand Up @@ -12,28 +12,6 @@
*/
class TagFixture extends CakeTestFixture {

/**
* Fields
*
* @var array
*/
public $fields = array(
'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary', 'comment' => 'ID'),
'block_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'comment' => 'ブロックID'),
'model' => array('type' => 'string', 'null' => false, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
'key' => array('type' => 'string', 'null' => false, 'default' => null, 'comment' => 'tag key | タグKey | | '),
'language_id' => array('type' => 'integer', 'null' => true, 'default' => null),
'name' => array('type' => 'string', 'null' => false, 'collate' => 'utf8_general_ci', 'comment' => 'タグ名', 'charset' => 'utf8'),
'created_user' => array('type' => 'integer', 'null' => true, 'default' => null, 'comment' => '作成者'),
'created' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => '作成日時'),
'modified_user' => array('type' => 'integer', 'null' => true, 'default' => null, 'comment' => '更新者'),
'modified' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => '更新日時'),
'indexes' => array(
'PRIMARY' => array('column' => 'id', 'unique' => 1)
),
'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB')
);

/**
* Records
*
Expand Down Expand Up @@ -114,4 +92,15 @@ class TagFixture extends CakeTestFixture {
),
);

/**
* Initialize the fixture.
*
* @return void
*/
public function init() {
require_once App::pluginPath('Tags') . 'Config' . DS . 'Schema' . DS . 'schema.php';
$this->fields = (new TagsSchema())->tables['tags'];
parent::init();
}

}
31 changes: 11 additions & 20 deletions Test/Fixture/TagsContentFixture.php
Expand Up @@ -12,26 +12,6 @@
*/
class TagsContentFixture extends CakeTestFixture {

/**
* Fields
*
* @var array
*/
public $fields = array(
'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary'),
'model' => array('type' => 'string', 'null' => false, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
'content_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 45),
'tag_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 45),
'created_user' => array('type' => 'integer', 'null' => true, 'default' => null, 'comment' => '作成者'),
'created' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => '作成日時'),
'modified_user' => array('type' => 'integer', 'null' => true, 'default' => null, 'comment' => '更新者'),
'modified' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => '更新日時'),
'indexes' => array(
'PRIMARY' => array('column' => 'id', 'unique' => 1)
),
'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB')
);

/**
* Records
*
Expand Down Expand Up @@ -80,4 +60,15 @@ class TagsContentFixture extends CakeTestFixture {
),
);

/**
* Initialize the fixture.
*
* @return void
*/
public function init() {
require_once App::pluginPath('Tags') . 'Config' . DS . 'Schema' . DS . 'schema.php';
$this->fields = (new TagsSchema())->tables['tags_contents'];
parent::init();
}

}

0 comments on commit 6280440

Please sign in to comment.