Skip to content

Commit

Permalink
update sorting column
Browse files Browse the repository at this point in the history
follow-up for b4fa772 (nextcloud#1056)

Signed-off-by: anoy <anoymouserver+github@mailbox.org>
  • Loading branch information
anoymouserver committed Feb 13, 2021
1 parent b4fa772 commit 42bbc1e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
20 changes: 10 additions & 10 deletions lib/Db/ItemMapperV2.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public function newest(string $userId): Entity
->innerJoin('items', FeedMapperV2::TABLE_NAME, 'feeds', 'items.feed_id = feeds.id')
->where('feeds.user_id = :userId')
->setParameter('userId', $userId)
->orderBy('items.updated_date', 'DESC')
->orderBy('items.last_modified', 'DESC')
->addOrderBy('items.id', 'DESC')
->setMaxResults(1);

Expand All @@ -312,15 +312,15 @@ public function findAllInFeedAfter(
$builder->select('items.*')
->from($this->tableName, 'items')
->innerJoin('items', FeedMapperV2::TABLE_NAME, 'feeds', 'items.feed_id = feeds.id')
->andWhere('items.updated_date >= :updatedSince')
->andWhere('items.last_modified >= :updatedSince')
->andWhere('feeds.user_id = :userId')
->andWhere('feeds.id = :feedId')
->setParameters([
'updatedSince' => $updatedSince,
'feedId' => $feedId,
'userId'=> $userId,
])
->orderBy('items.updated_date', 'DESC')
->orderBy('items.last_modified', 'DESC')
->addOrderBy('items.id', 'DESC');

if ($hideRead === true) {
Expand Down Expand Up @@ -350,11 +350,11 @@ public function findAllInFolderAfter(
->from($this->tableName, 'items')
->innerJoin('items', FeedMapperV2::TABLE_NAME, 'feeds', 'items.feed_id = feeds.id')
->innerJoin('feeds', FolderMapperV2::TABLE_NAME, 'folders', 'feeds.folder_id = folders.id')
->andWhere('items.updated_date >= :updatedSince')
->andWhere('items.last_modified >= :updatedSince')
->andWhere('feeds.user_id = :userId')
->andWhere('folders.id = :folderId')
->setParameters(['updatedSince' => $updatedSince, 'folderId' => $folderId, 'userId' => $userId])
->orderBy('items.updated_date', 'DESC')
->orderBy('items.last_modified', 'DESC')
->addOrderBy('items.id', 'DESC');

if ($hideRead === true) {
Expand All @@ -379,10 +379,10 @@ public function findAllAfter(string $userId, int $feedType, int $updatedSince):
$builder->select('items.*')
->from($this->tableName, 'items')
->innerJoin('items', FeedMapperV2::TABLE_NAME, 'feeds', 'items.feed_id = feeds.id')
->andWhere('items.updated_date >= :updatedSince')
->andWhere('items.last_modified >= :updatedSince')
->andWhere('feeds.user_id = :userId')
->setParameters(['updatedSince' => $updatedSince, 'userId' => $userId])
->orderBy('items.updated_date', 'DESC')
->orderBy('items.last_modified', 'DESC')
->addOrderBy('items.id', 'DESC');

switch ($feedType) {
Expand Down Expand Up @@ -430,7 +430,7 @@ public function findAllFeed(
->setParameter('feedId', $feedId)
->setMaxResults($limit)
->setFirstResult($offset)
->orderBy('items.updated_date', ($oldestFirst ? 'ASC' : 'DESC'))
->orderBy('items.last_modified', ($oldestFirst ? 'ASC' : 'DESC'))
->addOrderBy('items.id', ($oldestFirst ? 'ASC' : 'DESC'));

if ($search !== []) {
Expand Down Expand Up @@ -484,7 +484,7 @@ public function findAllFolder(
->setParameter('userId', $userId)
->setMaxResults($limit)
->setFirstResult($offset)
->orderBy('items.updated_date', ($oldestFirst ? 'ASC' : 'DESC'))
->orderBy('items.last_modified', ($oldestFirst ? 'ASC' : 'DESC'))
->addOrderBy('items.id', ($oldestFirst ? 'ASC' : 'DESC'));

if ($search !== []) {
Expand Down Expand Up @@ -530,7 +530,7 @@ public function findAllItems(
->setParameter('userId', $userId)
->setMaxResults($limit)
->setFirstResult($offset)
->orderBy('items.updated_date', ($oldestFirst ? 'ASC' : 'DESC'))
->orderBy('items.last_modified', ($oldestFirst ? 'ASC' : 'DESC'))
->addOrderBy('items.id', ($oldestFirst ? 'ASC' : 'DESC'));

if ($search !== []) {
Expand Down
52 changes: 26 additions & 26 deletions tests/Unit/Db/ItemMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ public function testNewest()

$this->builder->expects($this->once())
->method('orderBy')
->with('items.updated_date', 'DESC')
->with('items.last_modified', 'DESC')
->will($this->returnSelf());

$this->builder->expects($this->once())
Expand Down Expand Up @@ -493,7 +493,7 @@ public function testFindAllInFeedAfter()
$this->builder->expects($this->exactly(3))
->method('andWhere')
->withConsecutive(
['items.updated_date >= :updatedSince'],
['items.last_modified >= :updatedSince'],
['feeds.user_id = :userId'],
['feeds.id = :feedId']
)
Expand All @@ -510,7 +510,7 @@ public function testFindAllInFeedAfter()

$this->builder->expects($this->once())
->method('orderBy')
->with('items.updated_date', 'DESC')
->with('items.last_modified', 'DESC')
->will($this->returnSelf());

$this->builder->expects($this->once())
Expand Down Expand Up @@ -557,7 +557,7 @@ public function testFindAllInFeedAfterHideRead()
$this->builder->expects($this->exactly(4))
->method('andWhere')
->withConsecutive(
['items.updated_date >= :updatedSince'],
['items.last_modified >= :updatedSince'],
['feeds.user_id = :userId'],
['feeds.id = :feedId'],
['items.unread = 1']
Expand All @@ -575,7 +575,7 @@ public function testFindAllInFeedAfterHideRead()

$this->builder->expects($this->once())
->method('orderBy')
->with('items.updated_date', 'DESC')
->with('items.last_modified', 'DESC')
->will($this->returnSelf());

$this->builder->expects($this->once())
Expand Down Expand Up @@ -625,7 +625,7 @@ public function testFindAllInFolderAfter()
$this->builder->expects($this->exactly(3))
->method('andWhere')
->withConsecutive(
['items.updated_date >= :updatedSince'],
['items.last_modified >= :updatedSince'],
['feeds.user_id = :userId'],
['folders.id = :folderId']
)
Expand All @@ -642,7 +642,7 @@ public function testFindAllInFolderAfter()

$this->builder->expects($this->once())
->method('orderBy')
->with('items.updated_date', 'DESC')
->with('items.last_modified', 'DESC')
->will($this->returnSelf());

$this->builder->expects($this->once())
Expand Down Expand Up @@ -692,7 +692,7 @@ public function testFindAllInFolderAfterHideRead()
$this->builder->expects($this->exactly(4))
->method('andWhere')
->withConsecutive(
['items.updated_date >= :updatedSince'],
['items.last_modified >= :updatedSince'],
['feeds.user_id = :userId'],
['folders.id = :folderId'],
['items.unread = 1']
Expand All @@ -710,7 +710,7 @@ public function testFindAllInFolderAfterHideRead()

$this->builder->expects($this->once())
->method('orderBy')
->with('items.updated_date', 'DESC')
->with('items.last_modified', 'DESC')
->will($this->returnSelf());

$this->builder->expects($this->once())
Expand Down Expand Up @@ -757,7 +757,7 @@ public function testFindAllAfterUnread()
$this->builder->expects($this->exactly(3))
->method('andWhere')
->withConsecutive(
['items.updated_date >= :updatedSince'],
['items.last_modified >= :updatedSince'],
['feeds.user_id = :userId'],
['items.unread = 1']
)
Expand All @@ -773,7 +773,7 @@ public function testFindAllAfterUnread()

$this->builder->expects($this->once())
->method('orderBy')
->with('items.updated_date', 'DESC')
->with('items.last_modified', 'DESC')
->will($this->returnSelf());

$this->builder->expects($this->once())
Expand Down Expand Up @@ -820,7 +820,7 @@ public function testFindAllAfterStarred()
$this->builder->expects($this->exactly(3))
->method('andWhere')
->withConsecutive(
['items.updated_date >= :updatedSince'],
['items.last_modified >= :updatedSince'],
['feeds.user_id = :userId'],
['items.starred = 1']
)
Expand All @@ -836,7 +836,7 @@ public function testFindAllAfterStarred()

$this->builder->expects($this->once())
->method('orderBy')
->with('items.updated_date', 'DESC')
->with('items.last_modified', 'DESC')
->will($this->returnSelf());

$this->builder->expects($this->once())
Expand Down Expand Up @@ -886,7 +886,7 @@ public function testFindAllAfterInvalid()
$this->builder->expects($this->exactly(2))
->method('andWhere')
->withConsecutive(
['items.updated_date >= :updatedSince'],
['items.last_modified >= :updatedSince'],
['feeds.user_id = :userId']
)
->will($this->returnSelf());
Expand All @@ -901,7 +901,7 @@ public function testFindAllAfterInvalid()

$this->builder->expects($this->once())
->method('orderBy')
->with('items.updated_date', 'DESC')
->with('items.last_modified', 'DESC')
->will($this->returnSelf());

$this->builder->expects($this->once())
Expand Down Expand Up @@ -974,7 +974,7 @@ public function testFindAllItemsInvalid()

$this->builder->expects($this->once())
->method('orderBy')
->with('items.updated_date', 'DESC')
->with('items.last_modified', 'DESC')
->will($this->returnSelf());

$this->builder->expects($this->once())
Expand Down Expand Up @@ -1044,7 +1044,7 @@ public function testFindAllItemsUnread()

$this->builder->expects($this->once())
->method('orderBy')
->with('items.updated_date', 'DESC')
->with('items.last_modified', 'DESC')
->will($this->returnSelf());

$this->builder->expects($this->once())
Expand Down Expand Up @@ -1115,7 +1115,7 @@ public function testFindAllItemsStarred()

$this->builder->expects($this->once())
->method('orderBy')
->with('items.updated_date', 'DESC')
->with('items.last_modified', 'DESC')
->will($this->returnSelf());

$this->builder->expects($this->once())
Expand Down Expand Up @@ -1191,7 +1191,7 @@ public function testFindAllItemsStarredSearch()

$this->builder->expects($this->once())
->method('orderBy')
->with('items.updated_date', 'DESC')
->with('items.last_modified', 'DESC')
->will($this->returnSelf());

$this->builder->expects($this->once())
Expand Down Expand Up @@ -1262,7 +1262,7 @@ public function testFindAllFeed()

$this->builder->expects($this->once())
->method('orderBy')
->with('items.updated_date', 'DESC')
->with('items.last_modified', 'DESC')
->will($this->returnSelf());

$this->builder->expects($this->once())
Expand Down Expand Up @@ -1334,7 +1334,7 @@ public function testFindAllFeedHideRead()

$this->builder->expects($this->once())
->method('orderBy')
->with('items.updated_date', 'DESC')
->with('items.last_modified', 'DESC')
->will($this->returnSelf());

$this->builder->expects($this->once())
Expand Down Expand Up @@ -1410,7 +1410,7 @@ public function testFindAllFeedSearch()

$this->builder->expects($this->once())
->method('orderBy')
->with('items.updated_date', 'DESC')
->with('items.last_modified', 'DESC')
->will($this->returnSelf());

$this->builder->expects($this->once())
Expand Down Expand Up @@ -1493,7 +1493,7 @@ public function testFindAllFolderIdNull()

$this->builder->expects($this->once())
->method('orderBy')
->with('items.updated_date', 'DESC')
->with('items.last_modified', 'DESC')
->will($this->returnSelf());

$this->builder->expects($this->once())
Expand Down Expand Up @@ -1577,7 +1577,7 @@ public function testFindAllFolderHideRead()

$this->builder->expects($this->once())
->method('orderBy')
->with('items.updated_date', 'DESC')
->with('items.last_modified', 'DESC')
->will($this->returnSelf());

$this->builder->expects($this->once())
Expand Down Expand Up @@ -1661,7 +1661,7 @@ public function testFindAllFolderHideReadInvertOrder()

$this->builder->expects($this->once())
->method('orderBy')
->with('items.updated_date', 'ASC')
->with('items.last_modified', 'ASC')
->will($this->returnSelf());

$this->builder->expects($this->once())
Expand Down Expand Up @@ -1749,7 +1749,7 @@ public function testFindAllFolderSearchId()

$this->builder->expects($this->once())
->method('orderBy')
->with('items.updated_date', 'DESC')
->with('items.last_modified', 'DESC')
->will($this->returnSelf());

$this->builder->expects($this->once())
Expand Down

0 comments on commit 42bbc1e

Please sign in to comment.