diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2017-02-17 13:03:12 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2017-02-17 13:03:12 +0000 |
commit | f662bc5a866dc24580caa48952f25061bae60d1a (patch) | |
tree | 1cd3c637b0581056aa9ce608e08b974e870a4607 /app/models | |
parent | 5cc9ebbe14ce35de1ec45fc7abce3aa9f408ddf2 (diff) | |
parent | 60288d6c62d7e65ed5a93a72ba047ccaa2daa22b (diff) | |
download | gitlab-ce-f662bc5a866dc24580caa48952f25061bae60d1a.tar.gz |
Merge branch 'use-update-runner-service' into 'master'
Prefer service object over after_save hook
Closes #26921
See merge request !8664
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ci/runner.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb index ed1843ba005..07a086b0aca 100644 --- a/app/models/ci/runner.rb +++ b/app/models/ci/runner.rb @@ -22,8 +22,6 @@ module Ci scope :online, ->() { where('contacted_at > ?', LAST_CONTACT_TIME) } scope :ordered, ->() { order(id: :desc) } - after_save :tick_runner_queue, if: :form_editable_changed? - scope :owned_or_shared, ->(project_id) do joins('LEFT JOIN ci_runner_projects ON ci_runner_projects.runner_id = ci_runners.id') .where("ci_runner_projects.gl_project_id = :project_id OR ci_runners.is_shared = true", project_id: project_id) @@ -40,6 +38,8 @@ module Ci acts_as_taggable + after_destroy :cleanup_runner_queue + # Searches for runners matching the given query. # # This method uses ILIKE on PostgreSQL and LIKE on MySQL. @@ -147,14 +147,14 @@ module Ci private - def runner_queue_key - "runner:build_queue:#{self.token}" + def cleanup_runner_queue + Gitlab::Redis.with do |redis| + redis.del(runner_queue_key) + end end - def form_editable_changed? - FORM_EDITABLE.any? do |editable| - public_send("#{editable}_changed?") - end + def runner_queue_key + "runner:build_queue:#{self.token}" end def tag_constraints |