Class: LearnGitlab::Onboarding

Inherits:
Object
  • Object
show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
lib/learn_gitlab/onboarding.rb

Constant Summary collapse

ACTION_ISSUE_IDS =
{
  pipeline_created: 7,
  trial_started: 2,
  required_mr_approvals_enabled: 11,
  code_owners_enabled: 10
}.freeze
ACTION_PATHS =
[
  :issue_created,
  :git_write,
  :merge_request_created,
  :user_added,
  :security_scan_enabled
].freeze

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(namespace) ⇒ Onboarding

Returns a new instance of Onboarding.


22
23
24
# File 'lib/learn_gitlab/onboarding.rb', line 22

def initialize(namespace)
  @namespace = namespace
end

Instance Method Details

#completed_percentageObject


26
27
28
29
30
31
32
33
34
35
# File 'lib/learn_gitlab/onboarding.rb', line 26

def completed_percentage
  return 0 unless onboarding_progress

  attributes = onboarding_progress.attributes.symbolize_keys

  total_actions = action_columns.count
  completed_actions = action_columns.count { |column| attributes[column].present? }

  (completed_actions.to_f / total_actions.to_f * 100).round
end