summaryrefslogtreecommitdiffstats
path: root/db/feedmapper.php
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 /db/feedmapper.php
parent312796b1ca251567159368dddcaed1a3f0ddafc0 (diff)
autopurge all read items which are not starred if there are more than 1000
Diffstat (limited to 'db/feedmapper.php')
-rw-r--r--db/feedmapper.php24
1 files changed, 22 insertions, 2 deletions
diff --git a/db/feedmapper.php b/db/feedmapper.php
index d84cebad1..ba47d0a8a 100644
--- a/db/feedmapper.php
+++ b/db/feedmapper.php
@@ -57,8 +57,8 @@ class FeedMapper extends Mapper implements IMapper {
}
- private function findAllRows($sql, $params=array()){
- $result = $this->execute($sql, $params);
+ private function findAllRows($sql, $params=array(), $limit=null){
+ $result = $this->execute($sql, $params, $limit);
$feeds = array();
while($row = $result->fetchRow()){
@@ -121,4 +121,24 @@ class FeedMapper extends Mapper implements IMapper {
$this->execute($sql, $params);
}
+
+ public function getReadOlderThanThreshold($threshold){
+
+ // we want items that are not starred and not unread
+ $status = StatusFlag::STARRED | StatusFlag::UNREAD;
+ $sql = 'SELECT * FROM `*PREFIX*news_items` ' .
+ 'WHERE NOT ((`status` & ?) > 0)';
+
+ $params = array($status);
+ return $this->findAllRows($sql, $params, $threshold);
+ }
+
+
+ public function deleteReadOlderThanId($id){
+ $sql = 'DELETE FROM `*PREFIX*news_items` WHERE `id` < ?';
+ $params = array($id);
+ $this->execute($sql, $params);
+ }
+
+
} \ No newline at end of file