diff --git a/config/locales/de.yml b/config/locales/de.yml index d2d7664105..5a26b73253 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -7,6 +7,8 @@ de: label_report: "Report" label_columns: "Spalten" label_rows: "Zeilen" + label_yes: Ja + label_no: Nein label_group_by: "Gruppieren nach" label_group_by_add: "Gruppierung hinzufügen" @@ -22,3 +24,5 @@ de: validation_failure_date: "ist kein gültiges Datum" validation_failure_integer: "ist keine ganze Zahl" + + load_query_question: "Der Report wird %{size} Tabellen-Zellen haben, was sehr rechenintensiv sein kann. Wollen Sie dennoch versuchen, den Report durch zu führen?" diff --git a/config/locales/en.yml b/config/locales/en.yml index a879c64de6..c7d2be2370 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -13,6 +13,8 @@ en: label_filter: "Filter" label_filter_plural: "Filters" label_filter_add: Add Filter + label_yes: "Yes" + label_no: "No" label_count: Count label_sum: Sum @@ -22,3 +24,5 @@ en: validation_failure_date: "is not a valid date" validation_failure_integer: "is not a valid integer" + + load_query_question: "Report will have %{size} table cells and may take some time to render. Do you still want to try rendering it?" diff --git a/lib/report.rb b/lib/report.rb index 7e976637ee..9d533e3848 100644 --- a/lib/report.rb +++ b/lib/report.rb @@ -123,7 +123,7 @@ class Report < ActiveRecord::Base def_delegators :transformer, :column_first, :row_first def_delegators :chain, :empty_chain, :top, :bottom, :chain_collect, :sql_statement, :all_group_fields, :child, :clear, :result def_delegators :result, :each_direct_result, :recursive_each, :recursive_each_with_level, :each, :each_row, :count, - :units, :size, :final_number + :units, :final_number def_delegators :table, :row_index, :colum_index def to_a @@ -134,21 +134,27 @@ class Report < ActiveRecord::Base chain.to_s end + def size + size = 0 + recursive_each {|r| size += r.size } + size + end + def hash report_string = "" - + report_string.concat('filters: [') - report_string.concat(filters.map { |f| - f.class.underscore_name + f.operator.to_s + (f.values ? f.values.to_json : "") + report_string.concat(filters.map { |f| + f.class.underscore_name + f.operator.to_s + (f.values ? f.values.to_json : "") }.sort.join(', ')) report_string.concat(']') report_string.concat(', group_bys: {') - report_string.concat(group_bys.group_by(&:type).map { |t, gbs| + report_string.concat(group_bys.group_by(&:type).map { |t, gbs| "#{t} : [#{gbs.collect(&:class).collect(&:underscore_name).join(', ')}]" }.join(', ')) - + report_string.concat('}') report_string.hash