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:
authorShinya Maeda <shinya@gitlab.com>2018-05-31 10:12:20 +0300
committerShinya Maeda <shinya@gitlab.com>2018-06-06 11:49:48 +0300
commit3b569fceff09db6471a054128d2cbf268e63964d (patch)
treeda7fe1603c4aeb543c420c8f79ee1f464954c10f /app/models/ci
parentded38d5f48721b772fe23f3b7856c385f42b4fff (diff)
Clean up worker
Diffstat (limited to 'app/models/ci')
-rw-r--r--app/models/ci/build_trace_chunk.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/app/models/ci/build_trace_chunk.rb b/app/models/ci/build_trace_chunk.rb
index 4856f10846c..4884e355c36 100644
--- a/app/models/ci/build_trace_chunk.rb
+++ b/app/models/ci/build_trace_chunk.rb
@@ -50,6 +50,21 @@ module Ci
def finalize_fast_destroy(keys)
redis_delete_data(keys)
end
+
+ # Find stale live traces and return their build ids
+ def find_stale(finished_before: 1.hour.ago)
+ include(EachBatch)
+ .select(:build_id)
+ .group(:build_id)
+ .joins(:build)
+ .merge(Ci::Build.finished)
+ .where('ci_builds.finished_at < ?', finished_before)
+ .each_batch(column: :build_id) do |chunks|
+ build_ids = chunks.map { |chunk| [chunk.build_id] }
+
+ yield build_ids
+ end
+ end
end
##