summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2015-11-28 15:30:35 +0100
committerBernhard Posselt <dev@bernhard-posselt.com>2015-11-28 15:30:35 +0100
commit72e599bc87753e31bb9d161d341b7f95bd671658 (patch)
tree69b99f6a08534948e6625c01ef10f9ea704e14cb
parent6ca631ff5c0b7d3fef16604ee4ed87354e3bbf72 (diff)
Revert "also read duplicate feed items read"
-rw-r--r--db/itemmapper.php24
-rw-r--r--tests/integration/bootstrap.php1
-rw-r--r--tests/integration/db/ItemMapperTest.php4
-rw-r--r--tests/integration/fixtures/items.json14
-rw-r--r--tests/unit/db/ItemMapperTest.php20
5 files changed, 31 insertions, 32 deletions
diff --git a/db/itemmapper.php b/db/itemmapper.php
index 6033832a0..16d717963 100644
--- a/db/itemmapper.php
+++ b/db/itemmapper.php
@@ -129,21 +129,15 @@ class ItemMapper extends NewsMapper {
public function readFeed($feedId, $highestItemId, $time, $userId){
- $sql = 'UPDATE `*PREFIX*news_items`
- SET `status` = `status` & ?,
- `last_modified` = ?
- WHERE `id` IN (
- SELECT `b`.`id` FROM `*PREFIX*news_items` `a`,
- `*PREFIX*news_items` `b`
- WHERE `a`.`feed_id` = ?
- AND `a`.`id` <= ?
- AND `a`.`fingerprint` = `b`.`fingerprint`
- AND EXISTS (
- SELECT `id` FROM `*PREFIX*news_feeds`
- WHERE `user_id` = ?
- AND `id` = ?
- )
- )';
+ $sql = 'UPDATE `*PREFIX*news_items` ' .
+ 'SET `status` = `status` & ? ' .
+ ', `last_modified` = ? ' .
+ 'WHERE `feed_id` = ? ' .
+ 'AND `id` <= ? ' .
+ 'AND EXISTS (' .
+ 'SELECT * FROM `*PREFIX*news_feeds` ' .
+ 'WHERE `user_id` = ? ' .
+ 'AND `id` = ? ) ';
$params = [~StatusFlag::UNREAD, $time, $feedId, $highestItemId,
$userId, $feedId];
diff --git a/tests/integration/bootstrap.php b/tests/integration/bootstrap.php
index 7cd298beb..19a169a7e 100644
--- a/tests/integration/bootstrap.php
+++ b/tests/integration/bootstrap.php
@@ -162,7 +162,6 @@ class NewsIntegrationTest extends PHPUnit_Framework_TestCase {
$newItem->setLastModified($item['lastModified']);
$newItem->setEnclosureMime($item['enclosureMime']);
$newItem->setEnclosureLink($item['enclosureLink']);
- $newItem->generateSearchIndex();
return $this->itemMapper->insert($newItem);
}
diff --git a/tests/integration/db/ItemMapperTest.php b/tests/integration/db/ItemMapperTest.php
index 89fe98ebf..dcd101a9f 100644
--- a/tests/integration/db/ItemMapperTest.php
+++ b/tests/integration/db/ItemMapperTest.php
@@ -133,7 +133,7 @@ class ItemMapperTest extends NewsIntegrationTest {
30, 0, $status, false, $this->userId
);
- $this->assertEquals(2, count($items));
+ $this->assertEquals(1, count($items));
$item = $this->items['a title1'];
$item = $this->itemMapper->find($item->getId(), $this->userId);
@@ -210,7 +210,7 @@ class ItemMapperTest extends NewsIntegrationTest {
public function testFindAllUnreadOrStarred () {
$items = $this->itemMapper->findAllUnreadOrStarred($this->userId);
- $this->assertEquals(5, count($items));
+ $this->assertEquals(4, count($items));
}
diff --git a/tests/integration/fixtures/items.json b/tests/integration/fixtures/items.json
index c9f744a56..5396fde9b 100644
--- a/tests/integration/fixtures/items.json
+++ b/tests/integration/fixtures/items.json
@@ -101,18 +101,6 @@
],
"fourth feed": [
{
- "status": 2,
- "body": "this is a body",
- "title": "a title9",
- "author": "my author",
- "guid": "a title9",
- "url": "http://google.de",
- "pubDate": 1234,
- "lastModified": 1234,
- "enclosureMime": "video/mpeg",
- "enclosureLink": "http://google.de/web.webm"
- },
- {
"status": 0,
"body": "this is a body",
"title": "no folder",
@@ -153,4 +141,4 @@
"enclosureLink": "http://google.de/web.webm"
}
]
-}
+} \ No newline at end of file
diff --git a/tests/unit/db/ItemMapperTest.php b/tests/unit/db/ItemMapperTest.php
index 12597fb46..8b42aebb8 100644
--- a/tests/unit/db/ItemMapperTest.php
+++ b/tests/unit/db/ItemMapperTest.php
@@ -166,6 +166,24 @@ class ItemMapperTest extends \OCA\News\Tests\Unit\Db\MapperTestUtility {
}
+ public function testReadFeed(){
+ $sql = 'UPDATE `*PREFIX*news_items` ' .
+ 'SET `status` = `status` & ? ' .
+ ', `last_modified` = ? ' .
+ 'WHERE `feed_id` = ? ' .
+ 'AND `id` <= ? ' .
+ 'AND EXISTS (' .
+ 'SELECT * FROM `*PREFIX*news_feeds` ' .
+ 'WHERE `user_id` = ? ' .
+ 'AND `id` = ? ) ';
+ $params = [
+ ~StatusFlag::UNREAD, $this->updatedSince, 3, 6, $this->user, 3
+ ];
+ $this->setMapperResult($sql, $params);
+ $this->mapper->readFeed(3, 6, $this->updatedSince, $this->user);
+ }
+
+
public function testFindAllNew(){
$sql = 'AND `items`.`last_modified` >= ? ';
$sql = $this->makeSelectQueryStatus($sql, $this->status);
@@ -527,4 +545,4 @@ class ItemMapperTest extends \OCA\News\Tests\Unit\Db\MapperTestUtility {
}
-}
+} \ No newline at end of file