summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-09-13 17:59:16 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-09-13 17:59:16 +0200
commitdda579ccaac67b5f360af98926a1697389bdbc6c (patch)
tree63e9dc2af7218515323dee9e56d381decd811eef
parent7f3a42d9493c0c9e23ad6084a77bcd164b588ad2 (diff)
also store feeds per article when doing updates
-rw-r--r--CHANGELOG3
-rw-r--r--appinfo/database.xml7
-rw-r--r--appinfo/info.xml2
-rw-r--r--appinfo/version2
-rw-r--r--businesslayer/feedbusinesslayer.php8
-rw-r--r--db/feed.php2
-rw-r--r--tests/unit/businesslayer/FeedBusinessLayerTest.php40
7 files changed, 59 insertions, 5 deletions
diff --git a/CHANGELOG b/CHANGELOG
index e1471bb7a..f99bb2000 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,7 +1,8 @@
owncloud-news (1.601)
* Remove Google Reader import
* Replace Google Reader import with export and import of unread and starred articles
-* Set default autoPurgeLimit to 5000. People who update will have to adjust this if they want to
+* Autopurge limit is now added to the number of articles each feed gets when it updates
+* Fix CORS headers for OPTIONS request deeper than one level
owncloud-news (1.404)
* Fix bug on postgres databases that would not delete old articles
diff --git a/appinfo/database.xml b/appinfo/database.xml
index 7d3cf2378..9b04e9c84 100644
--- a/appinfo/database.xml
+++ b/appinfo/database.xml
@@ -114,6 +114,13 @@
<unsigned>true</unsigned>
</field>
<field>
+ <name>articles_per_update</name>
+ <type>integer</type>
+ <default>0</default>
+ <notnull>true</notnull>
+ <unsigned>true</unsigned>
+ </field>
+ <field>
<name>deleted_at</name>
<type>integer</type>
<default>0</default>
diff --git a/appinfo/info.xml b/appinfo/info.xml
index 15ddf6ee5..c6f87d3d6 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -5,6 +5,6 @@
<description>An RSS/Atom feed reader. Requires the App Framework app and backgroundjobs need to be enabled. See the README.rst in the apps top directory</description>
<licence>AGPL</licence>
<author>Alessandro Cosentino, Bernhard Posselt, Jan-Christoph Borchardt. Powered by SimplePie (Ryan Parman, Geoffrey Sneddon, Ryan McCue and contributors).</author>
- <version>1.404</version>
+ <version>1.405</version>
<require>5.0.6</require>
</info>
diff --git a/appinfo/version b/appinfo/version
index 9539f398d..3e3adf552 100644
--- a/appinfo/version
+++ b/appinfo/version
@@ -1 +1 @@
-1.404 \ No newline at end of file
+1.405 \ No newline at end of file
diff --git a/businesslayer/feedbusinesslayer.php b/businesslayer/feedbusinesslayer.php
index fca4a0c74..e337e5785 100644
--- a/businesslayer/feedbusinesslayer.php
+++ b/businesslayer/feedbusinesslayer.php
@@ -104,6 +104,7 @@ class FeedBusinessLayer extends BusinessLayer {
// insert feed
$feed->setFolderId($folderId);
$feed->setUserId($userId);
+ $feed->setArticlesPerUpdate(count($items));
$feed = $this->mapper->insert($feed);
// insert items in reverse order because the first one is usually the
@@ -175,8 +176,11 @@ class FeedBusinessLayer extends BusinessLayer {
list($feed, $items) = $this->feedFetcher->fetch(
$existingFeed->getUrl(), false);
- // keep the current faviconLink
- $feed->setFaviconLink($existingFeed->getFaviconLink());
+ // update number of articles on every feed update
+ if($existingFeed->getArticlesPerUpdate() !== count($items)) {
+ $existingFeed->setArticlesPerUpdate(count($items));
+ $this->mapper->update($existingFeed);
+ }
// insert items in reverse order because the first one is usually
// the newest item
diff --git a/db/feed.php b/db/feed.php
index e84e4489d..5e5bfcf5d 100644
--- a/db/feed.php
+++ b/db/feed.php
@@ -41,6 +41,7 @@ class Feed extends Entity implements IAPI {
public $link;
public $preventUpdate;
public $deletedAt;
+ public $articlesPerUpdate;
public function __construct(){
$this->addType('parentId', 'int');
@@ -49,6 +50,7 @@ class Feed extends Entity implements IAPI {
$this->addType('unreadCount', 'int');
$this->addType('preventUpdate', 'bool');
$this->addType('deletedAt', 'int');
+ $this->addType('articlesPerUpdate', 'int');
}
diff --git a/tests/unit/businesslayer/FeedBusinessLayerTest.php b/tests/unit/businesslayer/FeedBusinessLayerTest.php
index 17222c57b..550f37dcb 100644
--- a/tests/unit/businesslayer/FeedBusinessLayerTest.php
+++ b/tests/unit/businesslayer/FeedBusinessLayerTest.php
@@ -173,6 +173,7 @@ class FeedBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
$this->assertEquals($feed->getFolderId(), $folderId);
$this->assertEquals($feed->getUrl(), $url);
+ $this->assertEquals($feed->getArticlesPerUpdate(), 2);
}
@@ -240,6 +241,7 @@ class FeedBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
$feed = new Feed();
$feed->setId(3);
$feed->getUrl('test');
+ $feed->setArticlesPerUpdate(1);
$feed->setUrlHash('yo');
$item = new Item();
@@ -286,6 +288,43 @@ class FeedBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
$this->assertEquals($return, $feed);
}
+
+ public function testUpdateUpdatesArticlesPerFeedCount() {
+ $feed = new Feed();
+ $feed->setId(3);
+ $feed->getUrl('test');
+ $feed->setUrlHash('yo');
+
+ $existingFeed = new Feed();
+ $feed->setArticlesPerUpdate(2);
+
+ $item = new Item();
+ $item->setGuidHash(md5('hi'));
+ $item->setFeedId(3);
+ $items = array(
+ $item
+ );
+
+ $ex = new DoesNotExistException('hi');
+
+ $fetchReturn = array($feed, $items);
+
+ $this->feedMapper->expects($this->any())
+ ->method('find')
+ ->will($this->returnValue($existingFeed));
+
+ $this->fetcher->expects($this->once())
+ ->method('fetch')
+ ->will($this->returnValue(array($feed, $items)));
+
+ $this->feedMapper->expects($this->once())
+ ->method('update')
+ ->with($this->equalTo($existingFeed));
+
+
+ $this->feedBusinessLayer->update($feed->getId(), $this->user);
+ }
+
public function testUpdateFails(){
$feed = new Feed();
$feed->setId(3);
@@ -336,6 +375,7 @@ class FeedBusinessLayerTest extends \OCA\AppFramework\Utility\TestUtility {
$feed = new Feed();
$feed->setId(3);
$feed->getUrl('test');
+ $feed->setArticlesPerUpdate(1);
$item = new Item();
$item->setGuidHash(md5('hi'));