debian-mirror-gitlab/lib/gitlab/request_profiler.rb

37 lines
777 B
Ruby
Raw Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
2016-09-13 17:45:13 +05:30
require 'fileutils'
module Gitlab
module RequestProfiler
2019-12-04 20:38:33 +05:30
PROFILES_DIR = "#{Gitlab.config.shared.path}/tmp/requests_profiles"
2016-09-13 17:45:13 +05:30
2019-10-12 21:52:04 +05:30
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
2016-09-13 17:45:13 +05:30
def profile_token
Rails.cache.fetch('profile-token') do
Devise.friendly_token
end
end
module_function :profile_token
def remove_all_profiles
FileUtils.rm_rf(PROFILES_DIR)
end
module_function :remove_all_profiles
end
end