summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
authorAdam Niedzielski <adamsunday@gmail.com>2016-11-16 12:46:07 +0100
committerAdam Niedzielski <adamsunday@gmail.com>2016-11-16 12:46:07 +0100
commitef3be00a0297dfa31002616df6ee49a0e2132cb7 (patch)
tree2316894b87a84db4ecb8ddcd96eba046aeb2a47b /lib/api
parent0f48abf24b0ba34aebfc1d0d52e9e22648b7da1a (diff)
downloadgitlab-ce-ef3be00a0297dfa31002616df6ee49a0e2132cb7.tar.gz
Defer saving project services to the database if there are no user changesadam-build-missing-services-when-necessary
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/helpers.rb17
1 files changed, 1 insertions, 16 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index 3c9d7b1aaef..b4e0457f773 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -81,25 +81,10 @@ module API
end
def project_service
- @project_service ||= begin
- underscored_service = params[:service_slug].underscore
-
- if Service.available_services_names.include?(underscored_service)
- user_project.build_missing_services
-
- service_method = "#{underscored_service}_service"
-
- send_service(service_method)
- end
- end
-
+ @project_service ||= user_project.find_or_initialize_service(params[:service_slug].underscore)
@project_service || not_found!("Service")
end
- def send_service(service_method)
- user_project.send(service_method)
- end
-
def service_attributes
@service_attributes ||= project_service.fields.inject([]) do |arr, hash|
arr << hash[:name].to_sym