From 5ba75f4e228092edee4339977a17fb042c940800 Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Tue, 4 May 2021 21:05:27 +0200 Subject: 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 180ce80f4..76675a53f 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 be80a6c64..5b1a7ece1 100644 --- a/lib/Db/ItemMapperV2.php +++ b/lib/Db/ItemMapperV2.php @@ -302,7 +302,6 @@ class ItemMapperV2 extends NewsMapperV2 ->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 @@ class ItemMapperV2 extends NewsMapperV2 'feedId' => $feedId, 'userId'=> $userId, ]) - ->orderBy('items.last_modified', 'DESC') ->addOrderBy('items.id', 'DESC'); if ($hideRead === true) { @@ -377,7 +375,6 @@ class ItemMapperV2 extends NewsMapperV2 'folderId' => $folderId, 'userId' => $userId, ]) - ->orderBy('items.last_modified', 'DESC') ->addOrderBy('items.id', 'DESC'); if ($hideRead === true) { @@ -410,7 +407,6 @@ class ItemMapperV2 extends NewsMapperV2 '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 68bad19dc..9b6f02655 100644 --- a/tests/Unit/Db/ItemMapperAfterTest.php +++ b/tests/Unit/Db/ItemMapperAfterTest.php @@ -81,7 +81,7 @@ class ItemMapperAfterTest extends MapperTestUtility ]) ->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 @@ class ItemMapperAfterTest extends MapperTestUtility ->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 @@ class ItemMapperAfterTest extends MapperTestUtility ]) ->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 @@ class ItemMapperAfterTest extends MapperTestUtility ->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 @@ class ItemMapperAfterTest extends MapperTestUtility ->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 @@ class ItemMapperAfterTest extends MapperTestUtility ->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 @@ class ItemMapperAfterTest extends MapperTestUtility ]) ->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 @@ class ItemMapperAfterTest extends MapperTestUtility ]) ->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 12c022893..15ebbac1a 100644 --- a/tests/Unit/Db/ItemMapperTest.php +++ b/tests/Unit/Db/ItemMapperTest.php @@ -432,7 +432,7 @@ class ItemMapperTest extends MapperTestUtility ->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()); -- cgit v1.2.3