Class: Onboarding::Progress
Constant Summary
collapse
- ACTIONS =
[
:git_pull,
:git_write,
:merge_request_created,
:pipeline_created,
:user_added,
:trial_started,
:subscription_created,
:required_mr_approvals_enabled,
:code_owners_enabled,
:scoped_label_created,
:security_scan_enabled,
:issue_created,
:issue_auto_closed,
:repository_imported,
:repository_mirrored,
:secure_dependency_scanning_run,
:secure_container_scanning_run,
:secure_dast_run,
:secure_secret_detection_run,
:secure_coverage_fuzzing_run,
:secure_api_fuzzing_run,
:secure_cluster_image_scanning_run,
:license_scanning_run
].freeze
ApplicationRecord::MAX_PLUCK
ResetOnUnionError::MAX_RESET_PERIOD
Class Method Summary
collapse
Instance Method Summary
collapse
cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order
#serializable_hash
Class Method Details
.column_name(action) ⇒ Object
95
96
97
|
# File 'app/models/onboarding/progress.rb', line 95
def column_name(action)
:"#{action}_at"
end
|
.completed?(namespace, action) ⇒ Boolean
81
82
83
84
85
86
|
# File 'app/models/onboarding/progress.rb', line 81
def completed?(namespace, action)
return unless root_namespace?(namespace) && ACTIONS.include?(action)
action_column = column_name(action)
where(namespace: namespace).where.not(action_column => nil).exists?
end
|
.not_completed?(namespace_id, action) ⇒ Boolean
88
89
90
91
92
93
|
# File 'app/models/onboarding/progress.rb', line 88
def not_completed?(namespace_id, action)
return unless ACTIONS.include?(action)
action_column = column_name(action)
exists?(namespace_id: namespace_id, action_column => nil)
end
|
.onboard(namespace) ⇒ Object
56
57
58
59
60
|
# File 'app/models/onboarding/progress.rb', line 56
def onboard(namespace)
return unless root_namespace?(namespace)
create(namespace: namespace)
end
|
.onboarding?(namespace) ⇒ Boolean
62
63
64
|
# File 'app/models/onboarding/progress.rb', line 62
def onboarding?(namespace)
where(namespace: namespace).any?
end
|
.register(namespace, actions) ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'app/models/onboarding/progress.rb', line 66
def register(namespace, actions)
actions = Array(actions)
return unless root_namespace?(namespace) && actions.difference(ACTIONS).empty?
onboarding_progress = find_by(namespace: namespace)
return unless onboarding_progress
now = Time.current
nil_actions = actions.select { |action| onboarding_progress[column_name(action)].nil? }
return if nil_actions.empty?
updates = nil_actions.inject({}) { |sum, action| sum.merge!({ column_name(action) => now }) }
onboarding_progress.update!(updates)
end
|
Instance Method Details
#number_of_completed_actions ⇒ Object
106
107
108
|
# File 'app/models/onboarding/progress.rb', line 106
def number_of_completed_actions
attributes.(*ACTIONS.map { |action| self.class.column_name(action).to_s }).compact!.size
end
|