summaryrefslogtreecommitdiff
path: root/lib/api/builds.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/builds.rb')
-rw-r--r--lib/api/builds.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/api/builds.rb b/lib/api/builds.rb
index 6ecc248..f96c1d4 100644
--- a/lib/api/builds.rb
+++ b/lib/api/builds.rb
@@ -14,9 +14,12 @@ module API
required_attributes! [:token]
ActiveRecord::Base.transaction do
- builds = Build.all
- builds = builds.where(project_id: current_runner.projects) unless current_runner.shared?
- build = builds.first_pending
+ build = if current_runner.shared?
+ Build.first_pending
+ else
+ commits = Commit.where(project_id: current_runner.projects)
+ Build.where(commit_id: commits).first_pending
+ end
not_found! and return unless build