summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2015-11-27 21:44:48 +0100
committerBernhard Posselt <dev@bernhard-posselt.com>2015-11-27 21:44:48 +0100
commit32ef47a1ec3fc4da73408cf0d348581b219f72ee (patch)
tree632af02bcaa1fb9818cc6db9918b6d64247b4ad3
parent4831e4f754ef01442988f077d348c8a905ed1bf9 (diff)
add last feed update error to message
-rw-r--r--appinfo/database.xml6
-rw-r--r--appinfo/info.xml2
-rw-r--r--db/feed.php6
-rw-r--r--service/feedservice.php2
-rw-r--r--templates/part.navigation.feed.php2
-rw-r--r--tests/unit/db/FeedTest.php4
-rw-r--r--tests/unit/service/FeedServiceTest.php4
7 files changed, 21 insertions, 5 deletions
diff --git a/appinfo/database.xml b/appinfo/database.xml
index e242ad98c..a831b4211 100644
--- a/appinfo/database.xml
+++ b/appinfo/database.xml
@@ -148,6 +148,12 @@
<notnull>true</notnull>
</field>
<field>
+ <name>last_update_error</name>
+ <type>clob</type>
+ <default></default>
+ <notnull>false</notnull>
+ </field>
+ <field>
<name>deleted_at</name>
<type>integer</type>
<default>0</default>
diff --git a/appinfo/info.xml b/appinfo/info.xml
index b28dc55c7..0f47f335b 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -7,7 +7,7 @@
<author>Bernhard Posselt, Alessandro Cosentino, Jan-Christoph Borchardt</author>
<category>multimedia</category>
<licence>AGPL</licence>
- <version>6.1.3</version>
+ <version>6.1.4</version>
<namespace>News</namespace>
<!-- resources -->
diff --git a/db/feed.php b/db/feed.php
index 2960ecd25..5e2c7fab0 100644
--- a/db/feed.php
+++ b/db/feed.php
@@ -54,6 +54,8 @@ use \OCP\AppFramework\Db\Entity;
* @method void setArticlesPerUpdate(integer $value)
* @method integer getUpdateErrorCount()
* @method void setUpdateErrorCount(integer $value)
+ * @method string getLastUpdateError()
+ * @method void setLastUpdateError(string $value)
*/
class Feed extends Entity implements IAPI, \JsonSerializable {
@@ -79,6 +81,7 @@ class Feed extends Entity implements IAPI, \JsonSerializable {
protected $pinned;
protected $updateMode;
protected $updateErrorCount;
+ protected $lastUpdateError;
public function __construct(){
$this->addType('parentId', 'integer');
@@ -119,7 +122,8 @@ class Feed extends Entity implements IAPI, \JsonSerializable {
'fullTextEnabled',
'pinned',
'updateMode',
- 'updateErrorCount'
+ 'updateErrorCount',
+ 'lastUpdateError'
]);
$url = parse_url($this->link)['host'];
diff --git a/service/feedservice.php b/service/feedservice.php
index f3c64373d..a6ebc27cb 100644
--- a/service/feedservice.php
+++ b/service/feedservice.php
@@ -267,11 +267,13 @@ class FeedService extends Service {
// mark feed as successfully updated
$existingFeed->setUpdateErrorCount(0);
+ $existingFeed->setLastUpdateError('');
} catch(FetcherException $ex){
$existingFeed->setUpdateErrorCount(
$existingFeed->getUpdateErrorCount()+1
);
+ $existingFeed->setLastUpdateError($ex->getMessage());
}
$this->feedMapper->update($existingFeed);
diff --git a/templates/part.navigation.feed.php b/templates/part.navigation.feed.php
index b2d48b46d..aaf2c62de 100644
--- a/templates/part.navigation.feed.php
+++ b/templates/part.navigation.feed.php
@@ -33,7 +33,7 @@
ng-href="#/items/feeds/{{ feed.id }}/"
class="title"
ng-class="{'icon-rss': !feed.faviconLink}"
- title="{{ feed.updateErrorCount > 10 ? '<?php p($l->t('Feed failed to update more than 10 times')); ?>': feed.title }}">
+ title="{{ feed.updateErrorCount > 10 ? '<?php p($l->t('Feed failed to update more than 10 times')); ?>: ' + feed.lastUpdateError : feed.title }}">
{{ feed.title }}
</a>
diff --git a/tests/unit/db/FeedTest.php b/tests/unit/db/FeedTest.php
index 146215803..7a8c597ea 100644
--- a/tests/unit/db/FeedTest.php
+++ b/tests/unit/db/FeedTest.php
@@ -35,6 +35,7 @@ class FeedTest extends \PHPUnit_Framework_TestCase {
$feed->setPinned(true);
$feed->setUpdateMode(1);
$feed->setUpdateErrorCount(2);
+ $feed->setLastUpdateError('hi');
return $feed;
}
@@ -79,7 +80,8 @@ class FeedTest extends \PHPUnit_Framework_TestCase {
'fullTextEnabled' => true,
'pinned' => true,
'updateMode' => 1,
- 'updateErrorCount' => 2
+ 'updateErrorCount' => 2,
+ 'lastUpdateError' => 'hi'
], $feed->jsonSerialize());
}
diff --git a/tests/unit/service/FeedServiceTest.php b/tests/unit/service/FeedServiceTest.php
index 40ebf09d1..181642a45 100644
--- a/tests/unit/service/FeedServiceTest.php
+++ b/tests/unit/service/FeedServiceTest.php
@@ -510,12 +510,14 @@ class FeedServiceTest extends \PHPUnit_Framework_TestCase {
$feed = new Feed();
$feed->setId(3);
$feed->setUpdateErrorCount(0);
+ $feed->setLastUpdateError('');
$exptectedFeed = new Feed();
$exptectedFeed->setId(3);
$exptectedFeed->setUpdateErrorCount(1);
+ $exptectedFeed->setLastUpdateError('hi');
- $ex = new FetcherException('');
+ $ex = new FetcherException('hi');
$this->feedMapper->expects($this->at(0))
->method('find')