Added order:id support to post searching
This commit is contained in:
parent
736a25c3a4
commit
57dc7c5fad
6 changed files with 17 additions and 9 deletions
1
TODO
1
TODO
|
@ -25,7 +25,6 @@ everything related to posts:
|
|||
- special:disliked
|
||||
- special:fav
|
||||
- search order
|
||||
- order:id
|
||||
- order:time
|
||||
- order:comment_count
|
||||
- order:comment_time
|
||||
|
|
|
@ -3,16 +3,11 @@ namespace Szurubooru\SearchServices\Filters;
|
|||
|
||||
class BasicFilter implements IFilter
|
||||
{
|
||||
private $order;
|
||||
private $order = [];
|
||||
private $requirements = [];
|
||||
private $pageNumber;
|
||||
private $pageSize;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setOrder(['id' => self::ORDER_DESC]);
|
||||
}
|
||||
|
||||
public function getOrder()
|
||||
{
|
||||
return $this->order;
|
||||
|
|
|
@ -3,6 +3,7 @@ namespace Szurubooru\SearchServices\Filters;
|
|||
|
||||
class PostFilter extends BasicFilter implements IFilter
|
||||
{
|
||||
const ORDER_ID = 'id';
|
||||
const ORDER_FAV_TIME = 'lastFavTime';
|
||||
const ORDER_FAV_COUNT = 'favCount';
|
||||
const ORDER_TAG_COUNT = 'tagCount';
|
||||
|
@ -12,4 +13,9 @@ class PostFilter extends BasicFilter implements IFilter
|
|||
const REQUIREMENT_ID = 'id';
|
||||
const REQUIREMENT_DATE = 'uploadTime';
|
||||
const REQUIREMENT_HASH = 'name';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setOrder([self::ORDER_ID => self::ORDER_DESC]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,4 +5,9 @@ class UserFilter extends BasicFilter implements IFilter
|
|||
{
|
||||
const ORDER_NAME = 'name';
|
||||
const ORDER_REGISTRATION_TIME = 'registrationTime';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setOrder([self::ORDER_NAME => self::ORDER_ASC]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,10 @@ class PostSearchParser extends AbstractSearchParser
|
|||
|
||||
protected function getOrderColumn($token)
|
||||
{
|
||||
if ($token === 'fav_time')
|
||||
if ($token === 'id')
|
||||
return \Szurubooru\SearchServices\Filters\PostFilter::ORDER_ID;
|
||||
|
||||
elseif ($token === 'fav_time')
|
||||
return \Szurubooru\SearchServices\Filters\PostFilter::ORDER_FAV_TIME;
|
||||
|
||||
elseif ($token === 'fav_count')
|
||||
|
|
|
@ -70,7 +70,7 @@ class UserDaoFilterTest extends \Szurubooru\Tests\AbstractDatabaseTestCase
|
|||
public function testDefaultOrder()
|
||||
{
|
||||
list ($user1, $user2) = $this->prepareUsers();
|
||||
$this->doTestSorting(null, null, [$user2, $user1]);
|
||||
$this->doTestSorting(null, null, [$user1, $user2]);
|
||||
}
|
||||
|
||||
public function testOrderByNameAscending()
|
||||
|
|
Loading…
Reference in a new issue