From 78ccff843cc4896c931ae513ee91844835e2fbbc Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Tue, 4 Nov 2014 19:17:02 +0100 Subject: [PATCH] Removed tag autodeletion --- src/Dao/TagDao.php | 5 ----- src/Services/PostService.php | 2 -- src/Services/TagService.php | 9 --------- tests/Dao/TagDaoTest.php | 24 ------------------------ 4 files changed, 40 deletions(-) diff --git a/src/Dao/TagDao.php b/src/Dao/TagDao.php index e89a53bc..7f5d4d81 100644 --- a/src/Dao/TagDao.php +++ b/src/Dao/TagDao.php @@ -69,11 +69,6 @@ class TagDao extends AbstractDao implements ICrudDao return $this->arrayToEntities($arrayEntities); } - public function deleteUnused() - { - $this->pdo->deleteFrom($this->tableName)->where('usages = 0 AND banned != 1')->execute(); - } - public function export() { $exported = []; diff --git a/src/Services/PostService.php b/src/Services/PostService.php index ddc70ce8..b2709c07 100644 --- a/src/Services/PostService.php +++ b/src/Services/PostService.php @@ -127,7 +127,6 @@ class PostService return $savedPost; }; $ret = $this->transactionManager->commit($transactionFunc); - $this->tagService->deleteUnusedTags(); $this->tagService->exportJson(); return $ret; } @@ -168,7 +167,6 @@ class PostService return $this->postDao->save($post); }; $ret = $this->transactionManager->commit($transactionFunc); - $this->tagService->deleteUnusedTags(); $this->tagService->exportJson(); return $ret; } diff --git a/src/Services/TagService.php b/src/Services/TagService.php index d6eba376..047861da 100644 --- a/src/Services/TagService.php +++ b/src/Services/TagService.php @@ -75,15 +75,6 @@ class TagService $this->fileDao->save('tags.json', $json); } - public function deleteUnusedTags() - { - $transactionFunc = function() - { - $this->tagDao->deleteUnused(); - }; - $this->transactionManager->commit($transactionFunc); - } - public function createTags(array $tags) { $transactionFunc = function() use ($tags) diff --git a/tests/Dao/TagDaoTest.php b/tests/Dao/TagDaoTest.php index 4180ee03..6b362c5f 100644 --- a/tests/Dao/TagDaoTest.php +++ b/tests/Dao/TagDaoTest.php @@ -80,30 +80,6 @@ final class TagDaoTest extends AbstractDatabaseTestCase $this->assertEntitiesEqual($expected, $actual); } - public function testRemovingUnused() - { - $tag1 = new Tag(); - $tag1->setName('test1'); - $tag1->setCreationTime(date('c')); - $tag2 = new Tag(); - $tag2->setName('test2'); - $tag2->setCreationTime(date('c')); - $tagDao = $this->getTagDao(); - $tagDao->save($tag1); - $tagDao->save($tag2); - $pdo = $this->databaseConnection->getPDO(); - $pdo->exec('INSERT INTO postTags(postId, tagId) VALUES (1, 2)'); - $tag1 = $tagDao->findById($tag1->getId()); - $tag2 = $tagDao->findById($tag2->getId()); - $this->assertEquals(2, count($tagDao->findAll())); - $this->assertEquals(0, $tag1->getUsages()); - $this->assertEquals(1, $tag2->getUsages()); - $tagDao->deleteUnused(); - $this->assertEquals(1, count($tagDao->findAll())); - $this->assertNull($tagDao->findById($tag1->getId())); - $this->assertEntitiesEqual($tag2, $tagDao->findById($tag2->getId())); - } - private function getTagDao() { return new TagDao($this->databaseConnection);