2018-06-27 07:23:28 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-09-05 08:18:08 +00:00
|
|
|
class PruneOldEventsWorker
|
2017-11-28 16:08:30 +00:00
|
|
|
include ApplicationWorker
|
2020-02-10 12:08:59 +00:00
|
|
|
# rubocop:disable Scalability/CronWorkerContext
|
|
|
|
# This worker does not perform work scoped to a context
|
|
|
|
include CronjobQueue
|
|
|
|
# rubocop:enable Scalability/CronWorkerContext
|
2016-09-05 08:18:08 +00:00
|
|
|
|
2019-10-18 11:11:44 +00:00
|
|
|
feature_category_not_owned!
|
|
|
|
|
2020-02-03 09:08:42 +00:00
|
|
|
DELETE_LIMIT = 10_000
|
|
|
|
|
2016-09-05 08:18:08 +00:00
|
|
|
def perform
|
2019-10-11 00:06:24 +00:00
|
|
|
# Contribution calendar shows maximum 12 months of events, we retain 3 years for data integrity.
|
2020-02-03 09:08:42 +00:00
|
|
|
cutoff_date = (3.years + 1.day).ago
|
|
|
|
|
|
|
|
Event.unscoped.created_before(cutoff_date).delete_with_limit(DELETE_LIMIT)
|
2016-09-05 08:18:08 +00:00
|
|
|
end
|
|
|
|
end
|