diff options
author | Dmitry Chepurovskiy <dm3ch@dm3ch.net> | 2019-05-20 15:03:34 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-05-20 15:03:34 +0000 |
commit | 7017889d0b92dd8bd215770a9d4f823b5dc1f2eb (patch) | |
tree | 0cbce8dda9e38e89632f7d59a0b774873ec8bae5 /app | |
parent | 7115bd811f4bc87c0706fc2b876729878ad8fc5b (diff) | |
download | gitlab-ce-7017889d0b92dd8bd215770a9d4f823b5dc1f2eb.tar.gz |
Added filtering jobs by age to jobs/request API endpoint
Diffstat (limited to 'app')
-rw-r--r-- | app/models/ci/build.rb | 2 | ||||
-rw-r--r-- | app/services/ci/register_job_service.rb | 5 |
2 files changed, 7 insertions, 0 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 0a90995f689..1b67a7272bc 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -140,6 +140,8 @@ module Ci where("EXISTS (?)", matcher) end + scope :queued_before, ->(time) { where(arel_table[:queued_at].lt(time)) } + ## # TODO: Remove these mounters when we remove :ci_enable_legacy_artifacts feature flag mount_uploader :legacy_artifacts_file, LegacyArtifactUploader, mount_on: :artifacts_file diff --git a/app/services/ci/register_job_service.rb b/app/services/ci/register_job_service.rb index 6707a1363d0..baa3f898b2d 100644 --- a/app/services/ci/register_job_service.rb +++ b/app/services/ci/register_job_service.rb @@ -36,6 +36,11 @@ module Ci builds = builds.with_any_tags end + # pick builds that older than specified age + if params.key?(:job_age) + builds = builds.queued_before(params[:job_age].seconds.ago) + end + builds.each do |build| next unless runner.can_pick?(build) |