summaryrefslogtreecommitdiff
path: root/app/models/service.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-11-16 16:27:54 +0000
committerDouwe Maan <douwe@gitlab.com>2016-11-16 16:27:54 +0000
commit4e63411daae631c5e6221fe8ee674f55239e713b (patch)
tree3eca7c861bc047ec72f748fbed7a64056432e480 /app/models/service.rb
parent891465ba8cd57bb928e82ba070f2d7efb63f6282 (diff)
parentef3be00a0297dfa31002616df6ee49a0e2132cb7 (diff)
downloadgitlab-ce-4e63411daae631c5e6221fe8ee674f55239e713b.tar.gz
Merge branch 'adam-build-missing-services-when-necessary' into 'master'
Defer saving project services to the database if there are no user changes ## What does this MR do? It defers saving project services to the database as long as it is possible. It creates a project service when creating a project only if this project service has an active template. After that project services are saved on the first edit. ## Are there points in the code the reviewer needs to double check? - tests that used `build_missing_services` before the change - number of queries executed ## Why was this MR needed? Motivation in #22281 ## Does this MR meet the acceptance criteria? - [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - Tests - [x] Added for this feature/bug - [x] All builds are passing - [x] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html) - [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [x] Branch has no merge conflicts with `master` (if it does - rebase it please) - [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) ## What are the relevant issue numbers? Fixes #22281 See merge request !6958
Diffstat (limited to 'app/models/service.rb')
-rw-r--r--app/models/service.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/app/models/service.rb b/app/models/service.rb
index 625fbc48302..9d6ff190cdf 100644
--- a/app/models/service.rb
+++ b/app/models/service.rb
@@ -222,11 +222,11 @@ class Service < ActiveRecord::Base
]
end
- def self.create_from_template(project_id, template)
+ def self.build_from_template(project_id, template)
service = template.dup
service.template = false
service.project_id = project_id
- service if service.save
+ service
end
private