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