Skip to content

Commit

Permalink
change statement for deleting items with help from @Talon24
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Brahmer <[email protected]>
  • Loading branch information
Grotax committed Sep 25, 2020
1 parent f26cb24 commit 66ce13a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
20 changes: 10 additions & 10 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 15 additions & 8 deletions lib/Db/ItemMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,20 +357,27 @@ public function deleteReadOlderThanThreshold($threshold)
while ($row = $result->fetch()) {
$size = (int)$row['size'];
$limit = $size - $threshold;
$feed_id = $row['feed_id'];

if ($limit > 0) {
$params = [false, false, $row['feed_id'], $limit];

$sql = 'DELETE FROM `*PREFIX*news_items` ' .
'WHERE `id` IN (' .
'SELECT `id` FROM `*PREFIX*news_items` ' .
$params = [false, false, $feed_id, $limit];
$sql = 'SELECT `id` FROM `*PREFIX*news_items` ' .
'WHERE `unread` = ? ' .
'AND `starred` = ? ' .
'AND `feed_id` = ? ' .
'ORDER BY `id` ASC ' .
'LIMIT ?' .
')';

'LIMIT 1 ' .
'OFFSET ? ';
}
$limit_result = $this->execute($sql, $params);
if ($limit_row = $limit_result->fetch()) {
$limit_id = (int)$limit_row['id'];
$params = [false, false, $feed_id, $limit_id];
$sql = 'DELETE FROM `*PREFIX*news_items` ' .
'WHERE `unread` = ? ' .
'AND `starred` = ? ' .
'AND `feed_id` = ? ' .
'AND `id` < ? ';
$this->execute($sql, $params);
}
}
Expand Down

0 comments on commit 66ce13a

Please sign in to comment.