Removed tag autodeletion
This commit is contained in:
parent
248d20ede5
commit
78ccff843c
4 changed files with 0 additions and 40 deletions
|
@ -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 = [];
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue