diff options
author | Douwe Maan <douwe@gitlab.com> | 2018-10-08 13:41:09 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-10-08 13:41:09 +0300 |
commit | 651039ac5bd6cf617b6b497b8714430ace5cd43d (patch) | |
tree | dc4951fa129f277b4fd6c244b7ed112ef0005a2a /app/workers | |
parent | 0e8fc9262e344d386fc1d680e0af24e84ebb0912 (diff) | |
parent | 6170bfd8f5837f2d9d416559fdedab6ecbb16b84 (diff) |
Merge branch 'increase-event-retention-prune-old-events-worker' into 'master'
Prune events older than 2 years instead of 12 months
See merge request gitlab-org/gitlab-ce!22145
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/prune_old_events_worker.rb | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/app/workers/prune_old_events_worker.rb b/app/workers/prune_old_events_worker.rb index d44ad0d8030..dc4b7670131 100644 --- a/app/workers/prune_old_events_worker.rb +++ b/app/workers/prune_old_events_worker.rb @@ -6,14 +6,13 @@ class PruneOldEventsWorker # rubocop: disable CodeReuse/ActiveRecord def perform - # Contribution calendar shows maximum 12 months of events. - # Double nested query is used because MySQL doesn't allow DELETE subqueries - # on the same table. + # Contribution calendar shows maximum 12 months of events, we retain 2 years for data integrity. + # Double nested query is used because MySQL doesn't allow DELETE subqueries on the same table. Event.unscoped.where( '(id IN (SELECT id FROM (?) ids_to_remove))', Event.unscoped.where( 'created_at < ?', - (12.months + 1.day).ago) + (2.years + 1.day).ago) .select(:id) .limit(10_000)) .delete_all |