<commit_before>module ActiveWarehouse
	module View

		class TableView
			
			attr_reader :report, :column_dimension, :row_dimension, :current_params, :query_result, :fact_attributes,
									:data_columns, :row_crumbs, :column_crumbs, :with_totals, :sortable
									
			attr_accessor :ignore_columns
			
			def initialize(report, params, options = {})
				@report = report
				@with_totals = options.has_key?(:with_totals)
				@sortable = options.has_key?(:sortable)
				@ignore_columns = options.has_key?(:ignore_columns) ? options[:ignore_columns] : []
				
				@current_params = HashWithIndifferentAccess.new.merge(report.html_params)
				@column_dimension = ActiveWarehouse::Report::Dimension.column(@report, parse(params,:cstage, report.column_param_prefix))
				@row_dimension = ActiveWarehouse::Report::Dimension.row(@report, parse(params,:rstage, report.row_param_prefix))
				@column_crumbs = ColumnCrumb.gather(@column_dimension, @current_params)
        @row_crumbs = RowCrumb.gather(@row_dimension, @current_params)
				@query_result = execute_query
				@fact_attributes = []
				
				report.fact_attributes.each	do |fact_attribute|
          case fact_attribute
          when Symbol, String
            fact_attribute = report.fact_class.field_for_name(fact_attribute.to_s.dup)
            raise "Field name #{field_name} not defined in the fact #{fact_class}" if fact_attribute.nil?
          end			
					@fact_attributes << fact_attribute
				end
			end
			
			def parse(html_params, stage_key, param_prefix)
				params = HashWithIndifferentAccess.new
				if html_params[stage_key]
					params[:stage] = html_params[stage_key] 
					@current_params[stage_key] = html_params[stage_key]
				end	
				ancestors = HashWithIndifferentAccess.new				
		    html_params.each do |key, value|
					if key =~ /^#{param_prefix}_(.*)/
			      ancestors[$1] = value 
						@current_params[key] = value
					end
		    end				
				params[:ancestors] = ancestors
				params
			end
			
			def execute_query
				# REF - streamline cube.query to use the dimension objects including getting filters from them
		    report.cube.query(
		      :column_dimension_name => column_dimension.name, 
		      :column_hierarchy_name => column_dimension.hierarchy_name, 
		      :row_dimension_name => row_dimension.name, <commit_msg>error message reports something useful<commit_after>module ActiveWarehouse
	module View

		class TableView
			
			attr_reader :report, :column_dimension, :row_dimension, :current_params, :query_result, :fact_attributes,
									:data_columns, :row_crumbs, :column_crumbs, :with_totals, :sortable
									
			attr_accessor :ignore_columns
			
			def initialize(report, params, options = {})
				@report = report
				@with_totals = options.has_key?(:with_totals)
				@sortable = options.has_key?(:sortable)
				@ignore_columns = options.has_key?(:ignore_columns) ? options[:ignore_columns] : []
				
				@current_params = HashWithIndifferentAccess.new.merge(report.html_params)
				@column_dimension = ActiveWarehouse::Report::Dimension.column(@report, parse(params,:cstage, report.column_param_prefix))
				@row_dimension = ActiveWarehouse::Report::Dimension.row(@report, parse(params,:rstage, report.row_param_prefix))
				@column_crumbs = ColumnCrumb.gather(@column_dimension, @current_params)
        @row_crumbs = RowCrumb.gather(@row_dimension, @current_params)
				@query_result = execute_query
				@fact_attributes = []
				
				report.fact_attributes.each	do |fact_attribute_name|
          case fact_attribute_name
          when Symbol, String
            fact_attribute = report.fact_class.field_for_name(fact_attribute_name.to_s.dup)
            raise "Field name #{fact_attribute_name} not defined in the fact #{report.fact_class}" if fact_attribute.nil?
          end			
					@fact_attributes << fact_attribute
				end
			end
			
			def parse(html_params, stage_key, param_prefix)
				params = HashWithIndifferentAccess.new
				if html_params[stage_key]
					params[:stage] = html_params[stage_key] 
					@current_params[stage_key] = html_params[stage_key]
				end	
				ancestors = HashWithIndifferentAccess.new				
		    html_params.each do |key, value|
					if key =~ /^#{param_prefix}_(.*)/
			      ancestors[$1] = value 
						@current_params[key] = value
					end
		    end				
				params[:ancestors] = ancestors
				params
			end
			
			def execute_query
				# REF - streamline cube.query to use the dimension objects including getting filters from them
		    report.cube.query(
		      :column_dimension_name => column_dimension.name, 
		      :column_hierarchy_name => column_dimension.hierarchy_name, 
		      :row_dimension_name => row_dimension.name, 
{'fraction_non_alphanumeric': 0.09425531914893617, 'fraction_numerical': 0.000425531914893617, 'mean_word_length': 3.6452569169960474, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5827576', 'n_tokens_mistral': 1754, 'n_tokens_neox': 1435, 'n_words': 270}