summaryrefslogtreecommitdiffstats
path: root/db/postgres/itemmapper.php
diff options
context:
space:
mode:
Diffstat (limited to 'db/postgres/itemmapper.php')
-rw-r--r--db/postgres/itemmapper.php88
1 files changed, 44 insertions, 44 deletions
diff --git a/db/postgres/itemmapper.php b/db/postgres/itemmapper.php
index 593a0719a..643055f1a 100644
--- a/db/postgres/itemmapper.php
+++ b/db/postgres/itemmapper.php
@@ -20,50 +20,50 @@ use \OCA\News\Db\StatusFlag;
class ItemMapper extends \OCA\News\Db\ItemMapper {
- public function __construct(IDb $db){
- parent::__construct($db);
- }
-
-
- /**
- * Delete all items for feeds that have over $threshold unread and not
- * starred items
- */
- public function deleteReadOlderThanThreshold($threshold){
- $status = StatusFlag::STARRED | StatusFlag::UNREAD;
- $sql = 'SELECT COUNT(*) - `feeds`.`articles_per_update` AS `size`, ' .
- '`items`.`feed_id` AS `feed_id` ' .
- 'FROM `*PREFIX*news_items` `items` ' .
- 'JOIN `*PREFIX*news_feeds` `feeds` ' .
- 'ON `feeds`.`id` = `items`.`feed_id` ' .
- 'WHERE NOT ((`items`.`status` & ?) > 0) ' .
- 'GROUP BY `items`.`feed_id`, `feeds`.`articles_per_update` ' .
- 'HAVING COUNT(*) > ?';
- $params = [$status, $threshold];
- $result = $this->execute($sql, $params);
-
- while($row = $result->fetch()) {
-
- $size = (int) $row['size'];
- $limit = $size - $threshold;
-
- if($limit > 0) {
- $params = [$status, $row['feed_id'], $limit];
-
- $sql = 'DELETE FROM `*PREFIX*news_items` ' .
- 'WHERE `id` IN (' .
- 'SELECT `id` FROM `*PREFIX*news_items` ' .
- 'WHERE NOT ((`status` & ?) > 0) ' .
- 'AND `feed_id` = ? ' .
- 'ORDER BY `id` ASC ' .
- 'LIMIT ?' .
- ')';
-
- $this->execute($sql, $params);
- }
- }
-
- }
+ public function __construct(IDb $db){
+ parent::__construct($db);
+ }
+
+
+ /**
+ * Delete all items for feeds that have over $threshold unread and not
+ * starred items
+ */
+ public function deleteReadOlderThanThreshold($threshold){
+ $status = StatusFlag::STARRED | StatusFlag::UNREAD;
+ $sql = 'SELECT COUNT(*) - `feeds`.`articles_per_update` AS `size`, ' .
+ '`items`.`feed_id` AS `feed_id` ' .
+ 'FROM `*PREFIX*news_items` `items` ' .
+ 'JOIN `*PREFIX*news_feeds` `feeds` ' .
+ 'ON `feeds`.`id` = `items`.`feed_id` ' .
+ 'WHERE NOT ((`items`.`status` & ?) > 0) ' .
+ 'GROUP BY `items`.`feed_id`, `feeds`.`articles_per_update` ' .
+ 'HAVING COUNT(*) > ?';
+ $params = [$status, $threshold];
+ $result = $this->execute($sql, $params);
+
+ while($row = $result->fetch()) {
+
+ $size = (int) $row['size'];
+ $limit = $size - $threshold;
+
+ if($limit > 0) {
+ $params = [$status, $row['feed_id'], $limit];
+
+ $sql = 'DELETE FROM `*PREFIX*news_items` ' .
+ 'WHERE `id` IN (' .
+ 'SELECT `id` FROM `*PREFIX*news_items` ' .
+ 'WHERE NOT ((`status` & ?) > 0) ' .
+ 'AND `feed_id` = ? ' .
+ 'ORDER BY `id` ASC ' .
+ 'LIMIT ?' .
+ ')';
+
+ $this->execute($sql, $params);
+ }
+ }
+
+ }
} \ No newline at end of file