Added limit to preview.

This commit is contained in:
Martin Edenhofer 2015-10-29 19:20:22 +01:00
parent e727a548ed
commit e0293f08e5
4 changed files with 12 additions and 120 deletions

View file

@ -90,6 +90,7 @@ class ReportsController < ApplicationController
interval: get_params[:range], interval: get_params[:range],
selector: backend[:condition], selector: backend[:condition],
params: backend[:params], params: backend[:params],
sheet: params[:sheet],
) )
# generate sheet # generate sheet

View file

@ -64,18 +64,6 @@ class Report
adapter: Report::TicketMoved, adapter: Report::TicketMoved,
params: { type: 'out' }, params: { type: 'out' },
}, },
#{
# name: 'sla_in',
# display: 'SLA in',
# selected: false,
# dataDownload: true,
#},
#{
# name: 'sla_out',
# display: 'SLA out',
# selected: false,
# dataDownload: true,
#},
] ]
config[:metric][:count][:backend] = backend config[:metric][:count][:backend] = backend
@ -228,51 +216,6 @@ class Report
] ]
config[:metric][:create_channels][:backend] = backend config[:metric][:create_channels][:backend] = backend
config[:metric][:times] = {
name: 'times',
display: 'Times',
prio: 8000,
}
backend = [
{
name: 'first_response_average',
display: 'First Response average',
selected: true,
dataDownload: false,
},
{
name: 'first_response_max',
display: 'First Response max',
selected: false,
dataDownload: true,
},
{
name: 'first_response_min',
display: 'First Response min',
selected: false,
dataDownload: true,
},
{
name: 'solution_time_average',
display: 'Solution Time average',
selected: true,
dataDownload: false,
},
{
name: 'solution_time_max',
display: 'Solution Time max',
selected: false,
dataDownload: true,
},
{
name: 'solution_time_min',
display: 'Solution Time min',
selected: false,
dataDownload: true,
},
]
config[:metric][:times][:backend] = backend
config[:metric][:communication] = { config[:metric][:communication] = {
name: 'communication', name: 'communication',
display: 'Communication', display: 'Communication',
@ -358,64 +301,7 @@ class Report
}, },
] ]
config[:metric][:communication][:backend] = backend config[:metric][:communication][:backend] = backend
=begin
config[:metric][:sla] = {
name: 'sla',
display: 'SLAs',
prio: 6000,
}
backend = [
{
name: 'sla_out_1',
display: 'SLA (out) - <1h',
selected: false,
dataDownload: true,
},
{
name: 'sla_out_2',
display: 'SLA (out) - <2h',
selected: false,
dataDownload: true,
},
{
name: 'sla_out_4',
display: 'SLA (out) - <4h',
selected: false,
dataDownload: true,
},
{
name: 'sla_out_8',
display: 'SLA (out) - <8h',
selected: true,
dataDownload: true,
},
{
name: 'sla_in_1',
display: 'SLA (in) - <1h',
selected: true,
dataDownload: true,
},
{
name: 'sla_in_2',
display: 'SLA (in) - <2h',
selected: false,
dataDownload: true,
},
{
name: 'sla_in_4',
display: 'SLA (in) - <4h',
selected: false,
dataDownload: true,
},
{
name: 'sla_in_8',
display: 'SLA (in) - <8h',
selected: false,
dataDownload: true,
},
]
config[:metric][:sla][:backend] = backend
=end
config[:metric].each {|metric_key, metric_value| config[:metric].each {|metric_key, metric_value|
metric_value[:backend].each {|metric_backend| metric_value[:backend].each {|metric_backend|
metric_backend[:name] = "#{metric_key}::#{metric_backend[:name]}" metric_backend[:name] = "#{metric_key}::#{metric_backend[:name]}"

View file

@ -135,12 +135,17 @@ returns
field: params[:params][:field], field: params[:params][:field],
} }
limit = 1000
if !params[:sheet]
limit = 100
end
selector = params[:selector].clone selector = params[:selector].clone
if params[:params] && params[:params][:selector] if params[:params] && params[:params][:selector]
selector = selector.merge(params[:params][:selector]) selector = selector.merge(params[:params][:selector])
end end
result = SearchIndexBackend.selectors(['Ticket'], selector, nil, nil, aggs_interval) result = SearchIndexBackend.selectors(['Ticket'], selector, limit, nil, aggs_interval)
assets = {} assets = {}
result[:ticket_ids].each {|ticket_id| result[:ticket_ids].each {|ticket_id|
ticket_full = Ticket.find(ticket_id) ticket_full = Ticket.find(ticket_id)

View file

@ -269,7 +269,7 @@ get count of tickets and tickets which match on selector
=end =end
def self.selectors(index = nil, selectors = nil, _limit = 10, current_user = nil, aggs_interval = nil) def self.selectors(index = nil, selectors = nil, limit = 10, current_user = nil, aggs_interval = nil)
fail 'no selectors given' if !selectors fail 'no selectors given' if !selectors
url = build_url() url = build_url()
@ -284,7 +284,7 @@ get count of tickets and tickets which match on selector
url += '/_search' url += '/_search'
end end
data = selector2query(selectors, current_user, aggs_interval) data = selector2query(selectors, current_user, aggs_interval, limit)
Rails.logger.info "# curl -X POST \"#{url}\" \\" Rails.logger.info "# curl -X POST \"#{url}\" \\"
Rails.logger.debug " -d'#{data.to_json}'" Rails.logger.debug " -d'#{data.to_json}'"
@ -320,7 +320,7 @@ get count of tickets and tickets which match on selector
response.data response.data
end end
def self.selector2query(selector, _current_user, aggs_interval) def self.selector2query(selector, _current_user, aggs_interval, limit)
filter_must = [] filter_must = []
filter_must_not = [] filter_must_not = []
query_must = [] query_must = []
@ -351,7 +351,7 @@ get count of tickets and tickets which match on selector
end end
data = { data = {
query: {}, query: {},
size: 1000, size: limit,
} }
# add aggs to filter # add aggs to filter