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
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2017-11-10 22:57:11 +0300
committerYorick Peterse <yorickpeterse@gmail.com>2017-11-16 18:01:14 +0300
commitab16a6fb34c0f3e4d9afed3332c559868201e606 (patch)
treee878395b0f198b3db1cc014bad02361628f6206e /app/models/commit.rb
parent81e94ce1761b48b73be2a8d71938dfe934921e35 (diff)
Optimise getting the pipeline status of commits
This adds an optimised way of getting the latest pipeline status for a list of Commit objects (or just a single one).
Diffstat (limited to 'app/models/commit.rb')
-rw-r--r--app/models/commit.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index 6dba154a6ea..a31ebe9cc87 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -80,6 +80,7 @@ class Commit
@raw = raw_commit
@project = project
+ @statuses = {}
end
def id
@@ -236,11 +237,13 @@ class Commit
end
def status(ref = nil)
- @statuses ||= {}
-
return @statuses[ref] if @statuses.key?(ref)
- @statuses[ref] = pipelines.latest_status(ref)
+ @statuses[ref] = project.pipelines.latest_status_per_commit(id, ref)[id]
+ end
+
+ def set_status_for_ref(ref, status)
+ @statuses[ref] = status
end
def signature