summaryrefslogtreecommitdiffstats
path: root/businesslayer
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-04-16 23:52:23 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-04-16 23:52:23 +0200
commitcdbf8ca56d427b835ad675c92d57fe5a3140a2f5 (patch)
tree04367f8eda65cbc78de23ac830f693fe9cbca0ce /businesslayer
parente95c1af89093f74e2ba95864b99e3df63dc5dce1 (diff)
dont add items if they are already in the database
Diffstat (limited to 'businesslayer')
-rw-r--r--businesslayer/feedbusinesslayer.php15
1 files changed, 13 insertions, 2 deletions
diff --git a/businesslayer/feedbusinesslayer.php b/businesslayer/feedbusinesslayer.php
index f7666fc1c..ec6d7283a 100644
--- a/businesslayer/feedbusinesslayer.php
+++ b/businesslayer/feedbusinesslayer.php
@@ -72,14 +72,25 @@ class FeedBusinessLayer extends BusinessLayer {
// insert items in reverse order because the first one is usually the
// newest item
+ $unreadCount = 0;
for($i=count($items)-1; $i>=0; $i--){
$item = $items[$i];
$item->setFeedId($feed->getId());
- $this->itemMapper->insert($item);
+
+ // check if item exists (guidhash is the same)
+ // and ignore it if it does
+ try {
+ $this->itemMapper->findByGuidHash(
+ $item->getGuidHash(), $item->getFeedId(), $userId);
+ continue;
+ } catch(DoesNotExistException $ex){
+ $unreadCount += 1;
+ $this->itemMapper->insert($item);
+ }
}
// set unread count
- $feed->setUnreadCount(count($items));
+ $feed->setUnreadCount($unreadCount);
return $feed;
} catch(FetcherException $ex){