summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/Model/ProjectActivity.php8
1 files changed, 5 insertions, 3 deletions
diff --git a/app/Model/ProjectActivity.php b/app/Model/ProjectActivity.php
index d3aeefe5..74df26a1 100644
--- a/app/Model/ProjectActivity.php
+++ b/app/Model/ProjectActivity.php
@@ -168,9 +168,11 @@ class ProjectActivity extends Base
*/
public function cleanup($max)
{
- if ($this->db->table(self::TABLE)->count() > $max) {
- $subquery = $this->db->table(self::TABLE)->desc('id')->limit($max)->columns('id');
- $this->db->table(self::TABLE)->notInSubquery('id', $subquery)->remove();
+ $total = $this->db->table(self::TABLE)->count();
+
+ if ($total > $max) {
+ $ids = $this->db->table(self::TABLE)->asc('id')->limit($total - $max)->findAllByColumn('id');
+ $this->db->table(self::TABLE)->in('id', $ids)->remove();
}
}