Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2017-04-20 09:44:01 +0300
committerToon Claes <toon@gitlab.com>2017-04-24 11:07:01 +0300
commitc623c41c2f917e0773a6e3f0b6c78b027ca846f7 (patch)
tree83c081ab86fd07801fd9c9686245fe8cef1cc8b4 /app
parentccb9beeed0e418ef4dea201b3507bd2f4a14b4a2 (diff)
Use a better performing query to find all MRs for pipeline
And add some specs.
Diffstat (limited to 'app')
-rw-r--r--app/models/ci/pipeline.rb12
-rw-r--r--app/workers/expire_pipeline_cache_worker.rb4
2 files changed, 7 insertions, 9 deletions
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index bd5b0ed3cff..b5fe589706f 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -80,22 +80,22 @@ module Ci
end
after_transition [:created, :pending] => :running do |pipeline|
- pipeline.run_after_commit { PipelineMetricsWorker.perform_async(id) }
+ pipeline.run_after_commit { PipelineMetricsWorker.perform_async(pipeline.id) }
end
after_transition any => [:success] do |pipeline|
- pipeline.run_after_commit { PipelineMetricsWorker.perform_async(id) }
+ pipeline.run_after_commit { PipelineMetricsWorker.perform_async(pipeline.id) }
end
after_transition [:created, :pending, :running] => :success do |pipeline|
- pipeline.run_after_commit { PipelineSuccessWorker.perform_async(id) }
+ pipeline.run_after_commit { PipelineSuccessWorker.perform_async(pipeline.id) }
end
after_transition do |pipeline, transition|
next if transition.loopback?
pipeline.run_after_commit do
- PipelineHooksWorker.perform_async(id)
+ PipelineHooksWorker.perform_async(pipeline.id)
ExpirePipelineCacheWorker.perform_async(pipeline.id)
end
end
@@ -386,9 +386,7 @@ module Ci
# All the merge requests for which the current pipeline runs/ran against
def all_merge_requests
- @all_merge_requests ||= project.merge_requests
- .where(source_branch: ref)
- .select { |merge_request| merge_request.all_pipelines.includes(self) }
+ @all_merge_requests ||= project.merge_requests.where(source_branch: ref)
end
def detailed_status(current_user)
diff --git a/app/workers/expire_pipeline_cache_worker.rb b/app/workers/expire_pipeline_cache_worker.rb
index 65e7b091506..0210d459048 100644
--- a/app/workers/expire_pipeline_cache_worker.rb
+++ b/app/workers/expire_pipeline_cache_worker.rb
@@ -2,8 +2,8 @@ class ExpirePipelineCacheWorker
include Sidekiq::Worker
include PipelineQueue
- def perform(id)
- pipeline = Ci::Pipeline.find(id)
+ def perform(pipeline_id)
+ pipeline = Ci::Pipeline.find(pipeline_id)
project = pipeline.project
store = Gitlab::EtagCaching::Store.new