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:
authorKamil TrzciƄski <ayufan@ayufan.eu>2019-07-23 12:30:00 +0300
committerGrzegorz Bizon <grzegorz@gitlab.com>2019-07-23 12:30:00 +0300
commit3a4cb6d6759abbfd16e048413e8545d1d94e7d9e (patch)
treed6631643d70462ee38936708107bbedefbb5f45f /lib/gitlab/request_profiler.rb
parent5e102f17f0ef16d0fd1eff98b9229fea2bc1fec9 (diff)
Bring backward compatibility for request profiles
It seems that we missed the backward compatibility support for profiles in the existing folder. This commit also fixes some specs to be idempotent and work in a temporary directory which not always seems to be the case. This commit also brings the profile_spec.rb which seems to be missing.
Diffstat (limited to 'lib/gitlab/request_profiler.rb')
-rw-r--r--lib/gitlab/request_profiler.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/gitlab/request_profiler.rb b/lib/gitlab/request_profiler.rb
index 64593153686..033e451dbee 100644
--- a/lib/gitlab/request_profiler.rb
+++ b/lib/gitlab/request_profiler.rb
@@ -6,6 +6,21 @@ module Gitlab
module RequestProfiler
PROFILES_DIR = "#{Gitlab.config.shared.path}/tmp/requests_profiles".freeze
+ def all
+ Dir["#{PROFILES_DIR}/*.{html,txt}"].map do |path|
+ Profile.new(File.basename(path))
+ end.select(&:valid?)
+ end
+ module_function :all
+
+ def find(name)
+ file_path = File.join(PROFILES_DIR, name)
+ return unless File.exist?(file_path)
+
+ Profile.new(name)
+ end
+ module_function :find
+
def profile_token
Rails.cache.fetch('profile-token') do
Devise.friendly_token