2020-12-03 13:10:10 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class OnboardingProgressService
|
2021-02-23 10:10:47 -05:00
|
|
|
class Async
|
|
|
|
attr_reader :namespace_id
|
|
|
|
|
|
|
|
def initialize(namespace_id)
|
|
|
|
@namespace_id = namespace_id
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute(action:)
|
|
|
|
return unless OnboardingProgress.not_completed?(namespace_id, action)
|
|
|
|
|
|
|
|
Namespaces::OnboardingProgressWorker.perform_async(namespace_id, action)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.async(namespace_id)
|
|
|
|
Async.new(namespace_id)
|
|
|
|
end
|
|
|
|
|
2020-12-03 13:10:10 -05:00
|
|
|
def initialize(namespace)
|
2020-12-23 07:10:26 -05:00
|
|
|
@namespace = namespace&.root_ancestor
|
2020-12-03 13:10:10 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def execute(action:)
|
2020-12-23 07:10:26 -05:00
|
|
|
return unless @namespace
|
|
|
|
|
2021-01-11 07:10:41 -05:00
|
|
|
OnboardingProgress.register(@namespace, action)
|
2020-12-03 13:10:10 -05:00
|
|
|
end
|
|
|
|
end
|