15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'app/controllers/sql_monitor/tracking_sqls_controller.rb', line 15
def index
return not_found if Rails.env.production? || SqlMonitor.handler.nil?
@versions = SqlMonitor.handler.redis.get('all_versions')
if @versions.nil? || @versions.empty?
@versions = []
else
@versions = JSON.parse(SqlMonitor.handler.redis.get('all_versions'), {:symbolize_names => true})
end
@data = []
@selectedVersion = ''
if params[:version]
data = []
@selectedVersion = params[:version]
SqlMonitor.handler.redis.scan_each(match: @selectedVersion + ":*") do |v|
data << JSON.parse(SqlMonitor.handler.redis.mGet(v).first, {:symbolize_names => true}).merge({sql_key: v.split(':')[1]})
end
@data = format_data(sort_data(data, 'count'))
end
end
|