diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
commit | edaa33dee2ff2f7ea3fac488d41558eb5f86d68c (patch) | |
tree | 11f143effbfeba52329fb7afbd05e6e2a3790241 /app/models/onboarding_progress.rb | |
parent | d8a5691316400a0f7ec4f83832698f1988eb27c1 (diff) |
Add latest changes from gitlab-org/gitlab@14-7-stable-eev14.7.0-rc42
Diffstat (limited to 'app/models/onboarding_progress.rb')
-rw-r--r-- | app/models/onboarding_progress.rb | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/app/models/onboarding_progress.rb b/app/models/onboarding_progress.rb index c12309d1852..58b7848f7e2 100644 --- a/app/models/onboarding_progress.rb +++ b/app/models/onboarding_progress.rb @@ -20,7 +20,14 @@ class OnboardingProgress < ApplicationRecord :issue_created, :issue_auto_closed, :repository_imported, - :repository_mirrored + :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 ].freeze scope :incomplete_actions, -> (actions) do @@ -52,12 +59,19 @@ class OnboardingProgress < ApplicationRecord where(namespace: namespace).any? end - def register(namespace, action) - return unless root_namespace?(namespace) && ACTIONS.include?(action) + def register(namespace, actions) + actions = Array(actions) + return unless root_namespace?(namespace) && actions.difference(ACTIONS).empty? - action_column = column_name(action) - onboarding_progress = find_by(namespace: namespace, action_column => nil) - onboarding_progress&.update!(action_column => Time.current) + 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 def completed?(namespace, action) |