Class: Deforest::FilesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/deforest/files_controller.rb

Instance Method Summary collapse

Instance Method Details

#dashboardObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/deforest/files_controller.rb', line 7

def dashboard
  @top_percentile_methods = {}
  @medium_percentile_methods = {}
  @low_percentile_methods = {}

  Deforest::Log.percentile().each do |log, pcnt|
    if pcnt >= Deforest.most_used_percentile_threshold
      @top_percentile_methods["#{log.model_name}##{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.model_name}##{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.model_name}##{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

#indexObject



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/deforest/files_controller.rb', line 23

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

#showObject



37
38
39
40
# File 'app/controllers/deforest/files_controller.rb', line 37

def show
  @full_path = params[:path]
  # @full_path = "#{params[:path]}/#{params[:file_name]}.rb"
end