From c750e470d6bccf203929b96d6ce77905ea19d076 Mon Sep 17 00:00:00 2001 From: ARLakhin Date: Mon, 20 Apr 2026 23:40:48 +0300 Subject: [PATCH] =?UTF-8?q?SU2-33=20|=20=D0=9E=D1=87=D0=B8=D1=81=D1=82?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D1=85=20=D0=BE?= =?UTF-8?q?=D1=82=20=D0=BF=D1=83=D1=81=D1=82=D1=8B=D1=85=20=D1=81=D1=82?= =?UTF-8?q?=D1=80=D0=BE=D0=BA=20=D0=B8=20=D1=81=D1=82=D0=BE=D0=BB=D0=B1?= =?UTF-8?q?=D1=86=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/organisations_controller.rb | 25 ++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/app/controllers/organisations_controller.rb b/app/controllers/organisations_controller.rb index 2f2aa53..f489d6d 100644 --- a/app/controllers/organisations_controller.rb +++ b/app/controllers/organisations_controller.rb @@ -30,14 +30,15 @@ class OrganisationsController < ApplicationController statements_by_year_and_form = build_statements_by_year_and_form years = statements_by_year_and_form.keys.sort.reverse - grouped_rows = build_grouped_rows(statements_by_year_and_form, years) - + grouped_rows = clean_data(build_grouped_rows(statements_by_year_and_form, years)) @info_about_organisation = build_organization_payload(years) selected_doc = DOC_TYPES.fetch(@type_doc, DOC_TYPES[0]) @doc_name = selected_doc[:title] - @current_doc_info = @info_about_organisation[@doc_name] @current_doc_info1 = grouped_rows[@doc_name] + if !@current_doc_info1.values.first.nil? + @current_doc_info = @info_about_organisation[@doc_name][0..@current_doc_info1.values.first.size + 1] + end end @@ -95,6 +96,24 @@ class OrganisationsController < ApplicationController data end + def clean_data(data) + data.transform_values do |doc_type_data| + rows = doc_type_data.reject do |_, values| + values.all? { |value| value == "-" || value.nil? || value == ""} + end + + next {} if rows.empty? + + column_count = rows.values.map(&:size).max + columns_to_keep = (0...column_count).select do |i| + rows.values.any? { |values| values[i] != "-" && !values[i].nil? && values[i] != ""} + end + rows.transform_values do |values| + columns_to_keep.map { |i| values[i]} + end + end + end + def build_statements_by_year_and_form grouped = Hash.new { |hash, key| hash[key] = {} }