From 37e7d2597614d515e57a5fdd52159333238aa142 Mon Sep 17 00:00:00 2001 From: ARLakhin Date: Mon, 27 Apr 2026 13:02:28 +0300 Subject: [PATCH] =?UTF-8?q?SU2-33=20|=20=D0=98=D0=B7=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B0=20?= =?UTF-8?q?=D1=80=D0=B0=D1=81=D0=BA=D1=80=D0=B0=D1=81=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/organisations_helper.rb | 26 +++++++++++--------------- app/views/organisations/show.html.slim | 6 +++--- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/app/helpers/organisations_helper.rb b/app/helpers/organisations_helper.rb index 3ff6666..9050002 100644 --- a/app/helpers/organisations_helper.rb +++ b/app/helpers/organisations_helper.rb @@ -4,8 +4,8 @@ module OrganisationsHelper return nil if code.nil? || code.size < 2 prefix = code[0, 2] case prefix - when '21', '22', '23', '24' - '21-24' + when '21', '22', '23', '24', '25' + '21-25' else prefix end @@ -16,8 +16,8 @@ module OrganisationsHelper prefix = code[0, 2] return false unless prefix.match?(/\A\d{2}\z/) if type_data == 'min_max' - return false if %w[16 17].include?(prefix) - return true if %w[21 22 23 24 25 29].include?(prefix) + return false if %w[16 17 29].include?(prefix) || prefix.start_with?("3") + return true if %w[21 22 23 24 25].include?(prefix) return !code.end_with?('00') elsif type_data == 'comparsion' return code.end_with?('00') @@ -43,18 +43,14 @@ module OrganisationsHelper prepared_data = filtered_data.each_with_object({}) do |((_, code), values), result| next if code.nil? || !keep_code?(code) group = group_key(code) - result[group] ||= Hash.new { |h, k| h[k] = [] } - values.each_with_index do |value, index| - result[group][index + 1] << parse_number(value) - end + result[group] ||= [] + result[group] += values.map { |value| parse_number(value)} end - min_max_data = prepared_data.transform_values do |columns| - columns.transform_values do |values| - sorted = values.sort - size = sorted.size - p50 = size.odd? ? sorted[size / 2] : (sorted[size / 2 - 1] + sorted[size / 2]) / 2.0 - { min: sorted.first, p50: p50, max: sorted.last } - end + min_max_data = prepared_data.transform_values do |values| + sorted = values.sort + size = sorted.size + p50 = size.odd? ? sorted[size / 2] : (sorted[size / 2 - 1] + sorted[size / 2]) / 2.0 + { min: sorted.first, p50: p50, max: sorted.last } end elsif type_data == 'comparsion' prepared_data = filtered_data.each_with_object({}) do |((_, code), values), result| diff --git a/app/views/organisations/show.html.slim b/app/views/organisations/show.html.slim index 149efd3..ad5e286 100644 --- a/app/views/organisations/show.html.slim +++ b/app/views/organisations/show.html.slim @@ -43,9 +43,9 @@ - @current_doc_info1[key].each_with_index do |value, index| - key_group = key[1].nil? ? nil : group_key(key[1]) - if min_max_data.has_key?(key_group) && keep_code?(key[1]) - - min_value = min_max_data[key_group][index + 1][:min] - - max_value = min_max_data[key_group][index + 1][:max] - - p50 = min_max_data[key_group][index + 1][:p50] + - min_value = min_max_data[key_group][:min] + - max_value = min_max_data[key_group][:max] + - p50 = min_max_data[key_group][:p50] - color = get_color_for_cell(value, min: min_value, median: p50, max: max_value) td style="background-color: #{color}" = value - elsif comparsion_data.has_key?(key[1]) && keep_code?(key[1], type_data: 'comparsion')