summaryrefslogtreecommitdiffstats
path: root/bl
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-04-04 13:12:07 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-04-04 13:12:07 +0200
commit4b994c97ad878cc3886ffbea1a6a2bf6b4a98def (patch)
tree85d464146ad809a68372abed3a4026578d4006ad /bl
parent312796b1ca251567159368dddcaed1a3f0ddafc0 (diff)
autopurge all read items which are not starred if there are more than 1000
Diffstat (limited to 'bl')
-rw-r--r--bl/feedbl.php26
-rw-r--r--bl/folderbl.php2
2 files changed, 25 insertions, 3 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());
+ }
+ }
+
+
}
diff --git a/bl/folderbl.php b/bl/folderbl.php
index c17c516ba..3fcf48c7f 100644
--- a/bl/folderbl.php
+++ b/bl/folderbl.php
@@ -81,6 +81,6 @@ class FolderBl extends Bl {
$this->mapper->update($folder);
}
- // TODO: delete associated items
+
}