summaryrefslogtreecommitdiff
path: root/app/workers/prune_old_events_worker.rb
diff options
context:
space:
mode:
authorOlaf Tomalka <olaf.tomalka@gmail.com>2016-09-05 10:18:08 +0200
committerOlaf Tomalka <olaf.tomalka@gmail.com>2016-09-07 19:41:25 +0200
commite25b48ffcf1f7ef31df8d6c3366674e7f5c29893 (patch)
tree89e6864c451bfd3ebf68af14d12743304968cbc3 /app/workers/prune_old_events_worker.rb
parent6690fc70478b4d82c49689e9e13e414bc77bb271 (diff)
downloadgitlab-ce-e25b48ffcf1f7ef31df8d6c3366674e7f5c29893.tar.gz
Added cron to prune events older than 12 months.
Since contribution calendar shows only 12 months of activity, events older than that time are not visible anywhere and can be safely pruned saving big amount of database storage. Fixes #21164
Diffstat (limited to 'app/workers/prune_old_events_worker.rb')
-rw-r--r--app/workers/prune_old_events_worker.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/workers/prune_old_events_worker.rb b/app/workers/prune_old_events_worker.rb
new file mode 100644
index 00000000000..a0182fc67d0
--- /dev/null
+++ b/app/workers/prune_old_events_worker.rb
@@ -0,0 +1,8 @@
+class PruneOldEventsWorker
+ include Sidekiq::Worker
+
+ def perform
+ # Contribution calendar shows maximum 12 months of events
+ Event.where('created_at < ?', (12.months + 1.day).ago).destroy_all
+ end
+end