diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-09-13 21:34:54 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-09-13 21:34:54 +0200 |
commit | 6df3b51c550ba9d1d15924ed17c9d362ac908cf1 (patch) | |
tree | 477625cca14e7477d975ee6f81332dcde2008750 /db/postgres/itemmapper.php | |
parent | 9b1796fd37f3cf3fb6a8872262ce7c77c12cd389 (diff) |
fix sql
Diffstat (limited to 'db/postgres/itemmapper.php')
-rw-r--r-- | db/postgres/itemmapper.php | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/db/postgres/itemmapper.php b/db/postgres/itemmapper.php index ddf83ae10..0ccc9eeb4 100644 --- a/db/postgres/itemmapper.php +++ b/db/postgres/itemmapper.php @@ -45,10 +45,13 @@ class ItemMapper extends \OCA\News\Db\ItemMapper { */ public function deleteReadOlderThanThreshold($threshold){ $status = StatusFlag::STARRED | StatusFlag::UNREAD; - $sql = 'SELECT COUNT(*) `size`, `feed_id` ' . - 'FROM `*PREFIX*news_items` ' . - 'WHERE NOT ((`status` & ?) > 0) ' . - 'GROUP BY `feed_id` ' . + $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 = array($status, $threshold); $result = $this->execute($sql, $params); |