summaryrefslogtreecommitdiff
path: root/app/models/commit.rb
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2017-11-10 20:57:11 +0100
committerYorick Peterse <yorickpeterse@gmail.com>2017-11-16 16:01:14 +0100
commitab16a6fb34c0f3e4d9afed3332c559868201e606 (patch)
treee878395b0f198b3db1cc014bad02361628f6206e /app/models/commit.rb
parent81e94ce1761b48b73be2a8d71938dfe934921e35 (diff)
downloadgitlab-ce-ab16a6fb34c0f3e4d9afed3332c559868201e606.tar.gz
Optimise getting the pipeline status of commitsci-pipeline-status-query
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