From e4a2f4b90568d4315389d5a7c08930c9f94ce61d Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Tue, 4 May 2021 21:05:27 +0200 Subject: [PATCH] db: no longer order by items.last_modified Signed-off-by: Sean Molenaar --- CHANGELOG.md | 1 + lib/Db/ItemMapperV2.php | 4 ---- tests/Unit/Db/ItemMapperAfterTest.php | 16 ++++++++-------- tests/Unit/Db/ItemMapperTest.php | 2 +- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 180ce80f4f..76675a53f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ The format is almost based on [Keep a Changelog](https://keepachangelog.com/en/1 ### Changed ### Fixed +- newestId does not return newest ID but last updated # Releases ## [15.4.4] - 2021-05-21 diff --git a/lib/Db/ItemMapperV2.php b/lib/Db/ItemMapperV2.php index be80a6c64a..5b1a7ece14 100644 --- a/lib/Db/ItemMapperV2.php +++ b/lib/Db/ItemMapperV2.php @@ -302,7 +302,6 @@ 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.last_modified', 'DESC') ->addOrderBy('items.id', 'DESC') ->setMaxResults(1); @@ -337,7 +336,6 @@ public function findAllInFeedAfter( 'feedId' => $feedId, 'userId'=> $userId, ]) - ->orderBy('items.last_modified', 'DESC') ->addOrderBy('items.id', 'DESC'); if ($hideRead === true) { @@ -377,7 +375,6 @@ public function findAllInFolderAfter( 'folderId' => $folderId, 'userId' => $userId, ]) - ->orderBy('items.last_modified', 'DESC') ->addOrderBy('items.id', 'DESC'); if ($hideRead === true) { @@ -410,7 +407,6 @@ public function findAllAfter(string $userId, int $feedType, float $updatedSince) 'updatedSince' => number_format($updatedSince, 0, '.', ''), 'userId' => $userId, ]) - ->orderBy('items.last_modified', 'DESC') ->addOrderBy('items.id', 'DESC'); switch ($feedType) { diff --git a/tests/Unit/Db/ItemMapperAfterTest.php b/tests/Unit/Db/ItemMapperAfterTest.php index 68bad19dc3..9b6f02655d 100644 --- a/tests/Unit/Db/ItemMapperAfterTest.php +++ b/tests/Unit/Db/ItemMapperAfterTest.php @@ -81,7 +81,7 @@ public function testFindAllInFeedAfter() ]) ->will($this->returnSelf()); - $this->builder->expects($this->once()) + $this->builder->expects($this->never()) ->method('orderBy') ->with('items.last_modified', 'DESC') ->will($this->returnSelf()); @@ -152,7 +152,7 @@ public function testFindAllInFeedAfterHideRead() ->with('unread', true) ->will($this->returnSelf()); - $this->builder->expects($this->once()) + $this->builder->expects($this->never()) ->method('orderBy') ->with('items.last_modified', 'DESC') ->will($this->returnSelf()); @@ -220,7 +220,7 @@ public function testFindAllInFolderAfter() ]) ->will($this->returnSelf()); - $this->builder->expects($this->once()) + $this->builder->expects($this->never()) ->method('orderBy') ->with('items.last_modified', 'DESC') ->will($this->returnSelf()); @@ -294,7 +294,7 @@ public function testFindAllInFolderAfterHideRead() ->with('unread', true) ->will($this->returnSelf()); - $this->builder->expects($this->once()) + $this->builder->expects($this->never()) ->method('orderBy') ->with('items.last_modified', 'DESC') ->will($this->returnSelf()); @@ -363,7 +363,7 @@ public function testFindAllAfterUnread() ->with('unread', true) ->will($this->returnSelf()); - $this->builder->expects($this->once()) + $this->builder->expects($this->never()) ->method('orderBy') ->with('items.last_modified', 'DESC') ->will($this->returnSelf()); @@ -432,7 +432,7 @@ public function testFindAllAfterStarred() ->with('starred', true) ->will($this->returnSelf()); - $this->builder->expects($this->once()) + $this->builder->expects($this->never()) ->method('orderBy') ->with('items.last_modified', 'DESC') ->will($this->returnSelf()); @@ -495,7 +495,7 @@ public function testFindAllAfterAll() ]) ->will($this->returnSelf()); - $this->builder->expects($this->once()) + $this->builder->expects($this->never()) ->method('orderBy') ->with('items.last_modified', 'DESC') ->will($this->returnSelf()); @@ -561,7 +561,7 @@ public function testFindAllAfterInvalid() ]) ->will($this->returnSelf()); - $this->builder->expects($this->once()) + $this->builder->expects($this->never()) ->method('orderBy') ->with('items.last_modified', 'DESC') ->will($this->returnSelf()); diff --git a/tests/Unit/Db/ItemMapperTest.php b/tests/Unit/Db/ItemMapperTest.php index 12c0228933..15ebbac1af 100644 --- a/tests/Unit/Db/ItemMapperTest.php +++ b/tests/Unit/Db/ItemMapperTest.php @@ -432,7 +432,7 @@ public function testNewest() ->with('items', 'news_feeds', 'feeds', 'items.feed_id = feeds.id') ->will($this->returnSelf()); - $this->builder->expects($this->once()) + $this->builder->expects($this->never()) ->method('orderBy') ->with('items.last_modified', 'DESC') ->will($this->returnSelf());