Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlaf Tomalka <olaf.tomalka@gmail.com>2016-09-05 11:18:08 +0300
committerOlaf Tomalka <olaf.tomalka@gmail.com>2016-09-07 20:41:25 +0300
commite25b48ffcf1f7ef31df8d6c3366674e7f5c29893 (patch)
tree89e6864c451bfd3ebf68af14d12743304968cbc3 /app/workers
parent6690fc70478b4d82c49689e9e13e414bc77bb271 (diff)
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')
-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