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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-03 12:08:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-03 12:08:42 +0300
commitf14507e586a7f75f0fb71a1d8468b7361be860d4 (patch)
treea8aa547b517a7ae5626c902bfb558c1fc5386c4e /app/workers/prune_web_hook_logs_worker.rb
parentf4d27d532e3abeecd1caffeb3a56e698ae982e5b (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/workers/prune_web_hook_logs_worker.rb')
-rw-r--r--app/workers/prune_web_hook_logs_worker.rb17
1 files changed, 3 insertions, 14 deletions
diff --git a/app/workers/prune_web_hook_logs_worker.rb b/app/workers/prune_web_hook_logs_worker.rb
index 8e48b45fc34..69a1dd43e69 100644
--- a/app/workers/prune_web_hook_logs_worker.rb
+++ b/app/workers/prune_web_hook_logs_worker.rb
@@ -11,20 +11,9 @@ class PruneWebHookLogsWorker
# The maximum number of rows to remove in a single job.
DELETE_LIMIT = 50_000
- # rubocop: disable CodeReuse/ActiveRecord
def perform
- # MySQL doesn't allow "DELETE FROM ... WHERE id IN ( ... )" if the inner
- # query refers to the same table. To work around this we wrap the IN body in
- # another sub query.
- WebHookLog
- .where(
- 'id IN (SELECT id FROM (?) ids_to_remove)',
- WebHookLog
- .select(:id)
- .where('created_at < ?', 90.days.ago.beginning_of_day)
- .limit(DELETE_LIMIT)
- )
- .delete_all
+ cutoff_date = 90.days.ago.beginning_of_day
+
+ WebHookLog.created_before(cutoff_date).delete_with_limit(DELETE_LIMIT)
end
- # rubocop: enable CodeReuse/ActiveRecord
end