Added order:edit_time support for tag list
This commit is contained in:
parent
40e869b848
commit
2df43201ba
7 changed files with 32 additions and 0 deletions
|
@ -11,6 +11,7 @@ class TagEntityConverter extends AbstractEntityConverter implements IEntityConve
|
||||||
[
|
[
|
||||||
'name' => $entity->getName(),
|
'name' => $entity->getName(),
|
||||||
'creationTime' => $this->entityTimeToDbTime($entity->getCreationTime()),
|
'creationTime' => $this->entityTimeToDbTime($entity->getCreationTime()),
|
||||||
|
'lastEditTime' => $this->entityTimeToDbTime($entity->getLastEditTime()),
|
||||||
'banned' => intval($entity->isBanned()),
|
'banned' => intval($entity->isBanned()),
|
||||||
'category' => $entity->getCategory(),
|
'category' => $entity->getCategory(),
|
||||||
];
|
];
|
||||||
|
@ -21,6 +22,7 @@ class TagEntityConverter extends AbstractEntityConverter implements IEntityConve
|
||||||
$entity = new Tag(intval($array['id']));
|
$entity = new Tag(intval($array['id']));
|
||||||
$entity->setName($array['name']);
|
$entity->setName($array['name']);
|
||||||
$entity->setCreationTime($this->dbTimeToEntityTime($array['creationTime']));
|
$entity->setCreationTime($this->dbTimeToEntityTime($array['creationTime']));
|
||||||
|
$entity->setLastEditTime($this->dbTimeToEntityTime($array['lastEditTime']));
|
||||||
$entity->setMeta(Tag::META_USAGES, intval($array['usages']));
|
$entity->setMeta(Tag::META_USAGES, intval($array['usages']));
|
||||||
$entity->setBanned($array['banned']);
|
$entity->setBanned($array['banned']);
|
||||||
$entity->setCategory($array['category']);
|
$entity->setCategory($array['category']);
|
||||||
|
|
|
@ -5,6 +5,7 @@ final class Tag extends Entity
|
||||||
{
|
{
|
||||||
private $name;
|
private $name;
|
||||||
private $creationTime;
|
private $creationTime;
|
||||||
|
private $lastEditTime;
|
||||||
private $banned = false;
|
private $banned = false;
|
||||||
private $category = 'default';
|
private $category = 'default';
|
||||||
|
|
||||||
|
@ -33,6 +34,16 @@ final class Tag extends Entity
|
||||||
$this->creationTime = $creationTime;
|
$this->creationTime = $creationTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getLastEditTime()
|
||||||
|
{
|
||||||
|
return $this->lastEditTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setLastEditTime($lastEditTime)
|
||||||
|
{
|
||||||
|
$this->lastEditTime = $lastEditTime;
|
||||||
|
}
|
||||||
|
|
||||||
public function isBanned()
|
public function isBanned()
|
||||||
{
|
{
|
||||||
return $this->banned;
|
return $this->banned;
|
||||||
|
|
|
@ -6,6 +6,7 @@ class TagFilter extends BasicFilter implements IFilter
|
||||||
const ORDER_ID = 'id';
|
const ORDER_ID = 'id';
|
||||||
const ORDER_NAME = 'name';
|
const ORDER_NAME = 'name';
|
||||||
const ORDER_CREATION_TIME = 'creationTime';
|
const ORDER_CREATION_TIME = 'creationTime';
|
||||||
|
const ORDER_LAST_EDIT_TIME = 'lastEditTime';
|
||||||
const ORDER_USAGE_COUNT = 'usages';
|
const ORDER_USAGE_COUNT = 'usages';
|
||||||
|
|
||||||
const REQUIREMENT_PARTIAL_TAG_NAME = 'partialTagName';
|
const REQUIREMENT_PARTIAL_TAG_NAME = 'partialTagName';
|
||||||
|
|
|
@ -45,6 +45,7 @@ class TagSearchParser extends AbstractSearchParser
|
||||||
[['id'], TagFilter::ORDER_ID],
|
[['id'], TagFilter::ORDER_ID],
|
||||||
[['name'], TagFilter::ORDER_NAME],
|
[['name'], TagFilter::ORDER_NAME],
|
||||||
[['creation_time', 'creation_date', 'date'], TagFilter::ORDER_CREATION_TIME],
|
[['creation_time', 'creation_date', 'date'], TagFilter::ORDER_CREATION_TIME],
|
||||||
|
[['edit_time', 'edit_date'], TagFilter::ORDER_LAST_EDIT_TIME],
|
||||||
[['usage_count', 'usages'], TagFilter::ORDER_USAGE_COUNT],
|
[['usage_count', 'usages'], TagFilter::ORDER_USAGE_COUNT],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,6 +106,7 @@ class TagService
|
||||||
$tag->setName($tagName);
|
$tag->setName($tagName);
|
||||||
}
|
}
|
||||||
$tag->setCreationTime($this->timeService->getCurrentTime());
|
$tag->setCreationTime($this->timeService->getCurrentTime());
|
||||||
|
$tag->setLastEditTime($this->timeService->getCurrentTime());
|
||||||
$tagsToCreate[$tagNameGetter($tag)] = $tag;
|
$tagsToCreate[$tagNameGetter($tag)] = $tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,6 +138,8 @@ class TagService
|
||||||
{
|
{
|
||||||
$this->validator->validate($formData);
|
$this->validator->validate($formData);
|
||||||
|
|
||||||
|
$tag->setLastEditTime($this->timeService->getCurrentTime());
|
||||||
|
|
||||||
if ($formData->name !== null)
|
if ($formData->name !== null)
|
||||||
$this->updateTagName($tag, $formData->name);
|
$this->updateTagName($tag, $formData->name);
|
||||||
|
|
||||||
|
|
13
src/Upgrades/Upgrade44.php
Normal file
13
src/Upgrades/Upgrade44.php
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
namespace Szurubooru\Upgrades;
|
||||||
|
use Szurubooru\DatabaseConnection;
|
||||||
|
|
||||||
|
class Upgrade44 implements IUpgrade
|
||||||
|
{
|
||||||
|
public function run(DatabaseConnection $databaseConnection)
|
||||||
|
{
|
||||||
|
$pdo = $databaseConnection->getPDO();
|
||||||
|
$pdo->exec('ALTER TABLE tags ADD COLUMN lastEditTime TIMESTAMP NOT NULL DEFAULT 0');
|
||||||
|
$pdo->exec('UPDATE tags SET lastEditTime = creationTime');
|
||||||
|
}
|
||||||
|
}
|
|
@ -60,6 +60,7 @@ return [
|
||||||
$container->get(\Szurubooru\Upgrades\Upgrade41::class),
|
$container->get(\Szurubooru\Upgrades\Upgrade41::class),
|
||||||
$container->get(\Szurubooru\Upgrades\Upgrade42::class),
|
$container->get(\Szurubooru\Upgrades\Upgrade42::class),
|
||||||
$container->get(\Szurubooru\Upgrades\Upgrade43::class),
|
$container->get(\Szurubooru\Upgrades\Upgrade43::class),
|
||||||
|
$container->get(\Szurubooru\Upgrades\Upgrade44::class),
|
||||||
];
|
];
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue