From be3a0377dad4da54f5dbc51b88e39394c1b920be Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Tue, 22 May 2018 14:03:02 +0200 Subject: [PATCH] Fix memoization-related rubocop offense in project --- app/models/project.rb | 10 +++++++--- lib/gitlab/query_limiting/transaction.rb | 2 -- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index 5943a929364..e0f6c856f00 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1417,10 +1417,14 @@ class Project < ActiveRecord::Base Ci::Runner.from("(#{union.to_sql}) ci_runners") end - def any_runners?(&block) - @active_runners ||= all_runners.active + def active_runners + strong_memoize(:active_runners) do + all_runners.active + end + end - @active_runners.any?(&block) + def any_runners?(&block) + active_runners.any?(&block) end def valid_runners_token?(token) diff --git a/lib/gitlab/query_limiting/transaction.rb b/lib/gitlab/query_limiting/transaction.rb index cd712676263..66d7d9275cf 100644 --- a/lib/gitlab/query_limiting/transaction.rb +++ b/lib/gitlab/query_limiting/transaction.rb @@ -47,8 +47,6 @@ module Gitlab # Sends a notification based on the number of executed SQL queries. def act_upon_results - puts "XXXX\n\n\n\n\n #{count} \n\n\nXXXX" - return unless threshold_exceeded? error = ThresholdExceededError.new(error_message)