Class: Deforest::FilesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Deforest::FilesController
- Defined in:
- app/controllers/deforest/files_controller.rb
Instance Method Summary collapse
Instance Method Details
#dashboard ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/deforest/files_controller.rb', line 8 def dashboard @top_percentile_methods = {} @medium_percentile_methods = {} @low_percentile_methods = {} Deforest::Log.percentile(params[:dir] || "/app/models").each do |log, pcnt| if pcnt >= Deforest.most_used_percentile_threshold @top_percentile_methods[log.method_name] = { color: "highlight-red", total_call_count: log.count_sum, file_name: log.file_name, line_no: log.line_no } elsif pcnt <= Deforest.least_used_percentile_threshold @low_percentile_methods[log.method_name] = { color: "highlight-green", total_call_count: log.count_sum, file_name: log.file_name, line_no: log.line_no } else @medium_percentile_methods[log.method_name] = { color: "highlight-yellow", total_call_count: log.count_sum, file_name: log.file_name, line_no: log.line_no } end end end |
#extension_data ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/controllers/deforest/files_controller.rb', line 43 def extension_data result = Hash.new { |h,k| h[k] = [] } Deforest.track_dirs.each do |dir| Log.percentile(dir).each do |log, pcnt| if pcnt >= Deforest.most_used_percentile_threshold result[log.file_name] << { line_no: log.line_no, use_type: "most_used", call_count: log.count_sum } elsif pcnt <= Deforest.least_used_percentile_threshold result[log.file_name] << { line_no: log.line_no, use_type: "least_used", call_count: log.count_sum } else result[log.file_name] << { line_no: log.line_no, use_type: "medium_used", call_count: log.count_sum } end end end send_data result.to_json, filename: "deforest.json", type: "application/json", disposition: "attachment" end |
#index ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/deforest/files_controller.rb', line 24 def index @dirs = [] @files = [] @path = params[:path] || "#{Rails.root}/app/models" Dir.entries(@path)[2..-1].each do |m| if Dir.exists?("#{@path}/#{m}") @dirs << m else @files << m end end @dirs.uniq! end |
#show ⇒ Object
38 39 40 41 |
# File 'app/controllers/deforest/files_controller.rb', line 38 def show @full_path = params[:path] # @full_path = "#{params[:path]}/#{params[:file_name]}.rb" end |