From e0293f08e58e2bcacbc5780154eec2c5db07bf75 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 29 Oct 2015 19:20:22 +0100 Subject: [PATCH] Added limit to preview. --- app/controllers/reports_controller.rb | 1 + app/models/report.rb | 116 +------------------------- lib/report/ticket_generic_time.rb | 7 +- lib/search_index_backend.rb | 8 +- 4 files changed, 12 insertions(+), 120 deletions(-) diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 40d73a3bf..8d9893952 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -90,6 +90,7 @@ class ReportsController < ApplicationController interval: get_params[:range], selector: backend[:condition], params: backend[:params], + sheet: params[:sheet], ) # generate sheet diff --git a/app/models/report.rb b/app/models/report.rb index 0b450213c..51a4b52a4 100644 --- a/app/models/report.rb +++ b/app/models/report.rb @@ -64,18 +64,6 @@ class Report adapter: Report::TicketMoved, 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 @@ -228,51 +216,6 @@ class Report ] 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] = { name: 'communication', display: 'Communication', @@ -358,64 +301,7 @@ class Report }, ] 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| metric_value[:backend].each {|metric_backend| metric_backend[:name] = "#{metric_key}::#{metric_backend[:name]}" diff --git a/lib/report/ticket_generic_time.rb b/lib/report/ticket_generic_time.rb index c0b8d00ee..b913a19de 100644 --- a/lib/report/ticket_generic_time.rb +++ b/lib/report/ticket_generic_time.rb @@ -135,12 +135,17 @@ returns field: params[:params][:field], } + limit = 1000 + if !params[:sheet] + limit = 100 + end + selector = params[:selector].clone if params[:params] && params[:params][:selector] selector = selector.merge(params[:params][:selector]) end - result = SearchIndexBackend.selectors(['Ticket'], selector, nil, nil, aggs_interval) + result = SearchIndexBackend.selectors(['Ticket'], selector, limit, nil, aggs_interval) assets = {} result[:ticket_ids].each {|ticket_id| ticket_full = Ticket.find(ticket_id) diff --git a/lib/search_index_backend.rb b/lib/search_index_backend.rb index ff8bcac26..175bab482 100644 --- a/lib/search_index_backend.rb +++ b/lib/search_index_backend.rb @@ -269,7 +269,7 @@ get count of tickets and tickets which match on selector =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 url = build_url() @@ -284,7 +284,7 @@ get count of tickets and tickets which match on selector url += '/_search' 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.debug " -d'#{data.to_json}'" @@ -320,7 +320,7 @@ get count of tickets and tickets which match on selector response.data end - def self.selector2query(selector, _current_user, aggs_interval) + def self.selector2query(selector, _current_user, aggs_interval, limit) filter_must = [] filter_must_not = [] query_must = [] @@ -351,7 +351,7 @@ get count of tickets and tickets which match on selector end data = { query: {}, - size: 1000, + size: limit, } # add aggs to filter