diff options
author | Adam Niedzielski <adamsunday@gmail.com> | 2016-08-04 09:41:29 +0200 |
---|---|---|
committer | Adam Niedzielski <adamsunday@gmail.com> | 2016-08-04 09:41:29 +0200 |
commit | 9adddebc6deacd05e2de146ede640f690a17d7bf (patch) | |
tree | 4a16bf5f58542bc1a77a8f95fe7fd76c569f3127 /app/workers/remove_expired_members_worker.rb | |
parent | d95fd3cb9927d41b33e6991377ec060f2a12f4d5 (diff) | |
download | gitlab-ce-9adddebc6deacd05e2de146ede640f690a17d7bf.tar.gz |
Add worker which removes expired members.
Diffstat (limited to 'app/workers/remove_expired_members_worker.rb')
-rw-r--r-- | app/workers/remove_expired_members_worker.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/app/workers/remove_expired_members_worker.rb b/app/workers/remove_expired_members_worker.rb new file mode 100644 index 00000000000..30486b9e8a3 --- /dev/null +++ b/app/workers/remove_expired_members_worker.rb @@ -0,0 +1,13 @@ +class RemoveExpiredMembersWorker + include Sidekiq::Worker + + def perform + Member.includes(:created_by).where("expires_at <= ?", Time.current).find_each do |member| + begin + Members::DestroyService.new(member, member.created_by).execute + rescue => ex + logger.error("Expired Member ID=#{member.id} cannot be removed - #{ex}") + end + end + end +end |