diff options
author | Shinya Maeda <shinya@gitlab.com> | 2018-06-02 07:08:34 +0300 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2018-06-06 11:49:48 +0300 |
commit | 5a1ee0c391a06a323d960eab6ffb33dfcf2edca7 (patch) | |
tree | 0112d50f35408d4c04c4c6e8b4e473989a08eb97 /app/models/ci | |
parent | 2084e7ab9aad92d4a8196af01b9b8e02ffacb0a4 (diff) |
Fix the query to select stale live traces
Diffstat (limited to 'app/models/ci')
-rw-r--r-- | app/models/ci/build.rb | 16 |
1 files changed, 1 insertions, 15 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index f8fcab0e2f0..2d675726939 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -66,6 +66,7 @@ module Ci scope :last_month, ->() { where('created_at > ?', Date.today - 1.month) } scope :manual_actions, ->() { where(when: :manual, status: COMPLETED_STATUSES + [:manual]) } scope :ref_protected, -> { where(protected: true) } + scope :with_live_trace, -> { where('EXISTS (?)', Ci::BuildTraceChunk.where('ci_builds.id = ci_build_trace_chunks.build_id').select(1)) } scope :matches_tag_ids, -> (tag_ids) do matcher = ::ActsAsTaggableOn::Tagging @@ -583,21 +584,6 @@ module Ci super(options).merge(when: read_attribute(:when)) end - # Find stale live traces and return their build ids - def self.find_builds_from_stale_live_traces - binding.pry - - Ci::BuildTraceChunk - .include(EachBatch).select(:build_id).group(:build_id).joins(:build) - .merge(Ci::Build.finished).where('ci_builds.finished_at < ?', 1.hour.ago) - .each_batch(column: :build_id) do |chunks| - build_ids = chunks.map { |chunk| chunk.build_id } - - binding.pry - yield where(id: build_ids) - end - end - private def update_artifacts_size |