summaryrefslogtreecommitdiffstats
path: root/bl/feedbl.php
diff options
context:
space:
mode:
Diffstat (limited to 'bl/feedbl.php')
-rw-r--r--bl/feedbl.php26
1 files changed, 24 insertions, 2 deletions
diff --git a/bl/feedbl.php b/bl/feedbl.php
index 661f1f8f5..07cf5df8f 100644
--- a/bl/feedbl.php
+++ b/bl/feedbl.php
@@ -39,13 +39,16 @@ class FeedBl extends Bl {
private $feedFetcher;
private $itemMapper;
private $api;
+ private $autoPurgeCount;
public function __construct(FeedMapper $feedMapper, Fetcher $feedFetcher,
- ItemMapper $itemMapper, API $api){
+ ItemMapper $itemMapper, API $api,
+ $autoPurgeCount=0){
parent::__construct($feedMapper);
$this->feedFetcher = $feedFetcher;
$this->itemMapper = $itemMapper;
$this->api = $api;
+ $this->autoPurgeCount = $autoPurgeCount;
}
@@ -154,5 +157,24 @@ class FeedBl extends Bl {
$this->mapper->update($feed);
}
- // TODO: delete associated items
+
+ /**
+ * This method deletes all unread feeds that are not starred and over the
+ * count of $this->autoPurgeCount starting by the oldest. This is to clean
+ * up the database so that old entries dont spam your db. As criteria for
+ * old, the id is taken
+ */
+ public function autoPurgeOld(){
+ $readAndNotStarred =
+ $this->mapper->getReadOlderThanThreshold($this->autoPurgeCount);
+
+ // delete entries with a lower id than last item
+ if($this->autoPurgeCount > 0
+ && isset($readAndNotStarred[$this->autoPurgeCount-1])){
+ $this->mapper->deleteReadOlderThanId(
+ $readAndNotStarred[$this->autoPurgeCount-1]->getId());
+ }
+ }
+
+
}