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

expiring_worker.rb « members « workers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0d631af3a7cc63eb6414652e7bdc172050c591bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# frozen_string_literal: true

module Members
  class ExpiringWorker # rubocop:disable Scalability/IdempotentWorker
    include ApplicationWorker

    # rubocop:disable Scalability/CronWorkerContext
    # This worker does not perform work scoped to a context
    include CronjobQueue
    # rubocop:enable Scalability/CronWorkerContext

    data_consistency :sticky
    feature_category :system_access
    urgency :low

    BATCH_LIMIT = 500

    def perform
      return unless Feature.enabled?(:member_expiring_email_notification)

      limit_date = Member::DAYS_TO_EXPIRE.days.from_now.to_date

      expiring_members = Member.active.where(users: { user_type: :human }).expiring_and_not_notified(limit_date) # rubocop: disable CodeReuse/ActiveRecord

      expiring_members.each_batch(of: BATCH_LIMIT) do |members|
        members.pluck_primary_key.each do |member_id|
          Members::ExpiringEmailNotificationWorker.perform_async(member_id)
        end
      end
    end
  end
end