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:disliked
|
||||||
- special:fav
|
- special:fav
|
||||||
- search order
|
- search order
|
||||||
- order:id
|
|
||||||
- order:time
|
- order:time
|
||||||
- order:comment_count
|
- order:comment_count
|
||||||
- order:comment_time
|
- order:comment_time
|
||||||
|
|
|
@ -3,16 +3,11 @@ namespace Szurubooru\SearchServices\Filters;
|
||||||
|
|
||||||
class BasicFilter implements IFilter
|
class BasicFilter implements IFilter
|
||||||
{
|
{
|
||||||
private $order;
|
private $order = [];
|
||||||
private $requirements = [];
|
private $requirements = [];
|
||||||
private $pageNumber;
|
private $pageNumber;
|
||||||
private $pageSize;
|
private $pageSize;
|
||||||
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this->setOrder(['id' => self::ORDER_DESC]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getOrder()
|
public function getOrder()
|
||||||
{
|
{
|
||||||
return $this->order;
|
return $this->order;
|
||||||
|
|
|
@ -3,6 +3,7 @@ namespace Szurubooru\SearchServices\Filters;
|
||||||
|
|
||||||
class PostFilter extends BasicFilter implements IFilter
|
class PostFilter extends BasicFilter implements IFilter
|
||||||
{
|
{
|
||||||
|
const ORDER_ID = 'id';
|
||||||
const ORDER_FAV_TIME = 'lastFavTime';
|
const ORDER_FAV_TIME = 'lastFavTime';
|
||||||
const ORDER_FAV_COUNT = 'favCount';
|
const ORDER_FAV_COUNT = 'favCount';
|
||||||
const ORDER_TAG_COUNT = 'tagCount';
|
const ORDER_TAG_COUNT = 'tagCount';
|
||||||
|
@ -12,4 +13,9 @@ class PostFilter extends BasicFilter implements IFilter
|
||||||
const REQUIREMENT_ID = 'id';
|
const REQUIREMENT_ID = 'id';
|
||||||
const REQUIREMENT_DATE = 'uploadTime';
|
const REQUIREMENT_DATE = 'uploadTime';
|
||||||
const REQUIREMENT_HASH = 'name';
|
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_NAME = 'name';
|
||||||
const ORDER_REGISTRATION_TIME = 'registrationTime';
|
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)
|
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;
|
return \Szurubooru\SearchServices\Filters\PostFilter::ORDER_FAV_TIME;
|
||||||
|
|
||||||
elseif ($token === 'fav_count')
|
elseif ($token === 'fav_count')
|
||||||
|
|
|
@ -70,7 +70,7 @@ class UserDaoFilterTest extends \Szurubooru\Tests\AbstractDatabaseTestCase
|
||||||
public function testDefaultOrder()
|
public function testDefaultOrder()
|
||||||
{
|
{
|
||||||
list ($user1, $user2) = $this->prepareUsers();
|
list ($user1, $user2) = $this->prepareUsers();
|
||||||
$this->doTestSorting(null, null, [$user2, $user1]);
|
$this->doTestSorting(null, null, [$user1, $user2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testOrderByNameAscending()
|
public function testOrderByNameAscending()
|
||||||
|
|
Loading…
Reference in a new issue