Class: QueryTracker::Printer::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/query_tracker/printer/base.rb

Direct Known Subclasses

Console, Html, HtmlCompare

Instance Method Summary collapse

Instance Method Details

#css_contentObject

this js is not used as erb, it could be changed



37
38
39
# File 'lib/query_tracker/printer/base.rb', line 37

def css_content
  File.read(@css_path)
end

#filter_data(data) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/query_tracker/printer/base.rb', line 4

def filter_data data
  data = data.select { |_, v| v[:count] >= Configuration.ignore_table_count }
  data = data.sort_by { |_, v| -v[:count] }.each do |_category, info|
    info[:location] = info[:location].sort_by do |_, detail|
      -detail[:count]
    end.first(Configuration.max_locations_per_table).to_h
  end
  data.to_h
end

#js_contentObject

this js is not used as erb, it could be changed



32
33
34
# File 'lib/query_tracker/printer/base.rb', line 32

def js_content
  File.read(@js_path)
end

#open_file(html_dest) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/query_tracker/printer/base.rb', line 23

def open_file html_dest
  if ENV['WSL_DISTRIBUTION']
    Launchy.open("file://wsl%24/#{ENV['WSL_DISTRIBUTION']}#{html_dest}")
  else
    Launchy.open(html_dest)
  end
end

#sort_data(data) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/query_tracker/printer/base.rb', line 14

def sort_data data
  data = data.sort_by { |_, v| -v[:count] }.each do |_category, info|
    info[:location] = info[:location].sort_by do |_, detail|
      -detail[:count]
    end.to_h
  end
  data.to_h
end