Removed tag autodeletion

This commit is contained in:
Marcin Kurczewski 2014-11-04 19:17:02 +01:00
parent 248d20ede5
commit 78ccff843c
4 changed files with 0 additions and 40 deletions

View file

@ -69,11 +69,6 @@ class TagDao extends AbstractDao implements ICrudDao
return $this->arrayToEntities($arrayEntities); return $this->arrayToEntities($arrayEntities);
} }
public function deleteUnused()
{
$this->pdo->deleteFrom($this->tableName)->where('usages = 0 AND banned != 1')->execute();
}
public function export() public function export()
{ {
$exported = []; $exported = [];

View file

@ -127,7 +127,6 @@ class PostService
return $savedPost; return $savedPost;
}; };
$ret = $this->transactionManager->commit($transactionFunc); $ret = $this->transactionManager->commit($transactionFunc);
$this->tagService->deleteUnusedTags();
$this->tagService->exportJson(); $this->tagService->exportJson();
return $ret; return $ret;
} }
@ -168,7 +167,6 @@ class PostService
return $this->postDao->save($post); return $this->postDao->save($post);
}; };
$ret = $this->transactionManager->commit($transactionFunc); $ret = $this->transactionManager->commit($transactionFunc);
$this->tagService->deleteUnusedTags();
$this->tagService->exportJson(); $this->tagService->exportJson();
return $ret; return $ret;
} }

View file

@ -75,15 +75,6 @@ class TagService
$this->fileDao->save('tags.json', $json); $this->fileDao->save('tags.json', $json);
} }
public function deleteUnusedTags()
{
$transactionFunc = function()
{
$this->tagDao->deleteUnused();
};
$this->transactionManager->commit($transactionFunc);
}
public function createTags(array $tags) public function createTags(array $tags)
{ {
$transactionFunc = function() use ($tags) $transactionFunc = function() use ($tags)

View file

@ -80,30 +80,6 @@ final class TagDaoTest extends AbstractDatabaseTestCase
$this->assertEntitiesEqual($expected, $actual); $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() private function getTagDao()
{ {
return new TagDao($this->databaseConnection); return new TagDao($this->databaseConnection);