Sha256: 5083ee34b149fc903ac9c2011ff982a6e65a6e4e9d2871f230c7d4688066ee8f

Contents?: true

Size: 1.55 KB

Versions: 120

Compression:

Stored size: 1.55 KB

Contents

module ForestLiana
  module AdapterHelper
    ADAPTER_MYSQL2 = 'Mysql2'

    def self.format_column_name(table_name, column_name)
      quoted_table_name = ActiveRecord::Base.connection.quote_table_name(table_name)
      quoted_column_name = ActiveRecord::Base.connection.quote_column_name(column_name)
      "#{quoted_table_name}.#{quoted_column_name}"
    end

    def self.cast_boolean(value)
      if ['MySQL', 'SQLite'].include?(ActiveRecord::Base.connection.adapter_name)
        value === 'true' ? 1 : 0;
      else
        value
      end
    end

    def self.format_live_query_value_result(result)
      # NOTICE: The adapters have their own specific format for the live query value chart results.
      case ActiveRecord::Base.connection.adapter_name
      when ADAPTER_MYSQL2
        { 'value' => result.first.first }
      else
        result.first
      end
    end

    def self.format_live_query_pie_result(result)
      # NOTICE: The adapters have their own specific format for the live query pie chart results.
      case ActiveRecord::Base.connection.adapter_name
      when ADAPTER_MYSQL2
        result.map { |value| { 'key' => value[0], 'value' => value[1] } }
      else
        result.to_a
      end
    end

    def self.format_live_query_line_result(result)
      # NOTICE: The adapters have their own specific format for the live query line chart results.
      case ActiveRecord::Base.connection.adapter_name
      when ADAPTER_MYSQL2
        result.map { |value| { 'key' => value[0], 'value' => value[1] } }
      else
        result
      end
    end
  end
end

Version data entries

120 entries across 120 versions & 1 rubygems

Version Path
forest_liana-2.15.1 app/helpers/forest_liana/adapter_helper.rb
forest_liana-3.0.0.pre.beta.7 app/helpers/forest_liana/adapter_helper.rb
forest_liana-3.0.0.pre.beta.6 app/helpers/forest_liana/adapter_helper.rb
forest_liana-2.15.0 app/helpers/forest_liana/adapter_helper.rb
forest_liana-3.0.0.pre.beta.5 app/helpers/forest_liana/adapter_helper.rb
forest_liana-2.14.7 app/helpers/forest_liana/adapter_helper.rb
forest_liana-3.0.0.pre.beta.3 app/helpers/forest_liana/adapter_helper.rb
forest_liana-3.0.0.pre.beta.2 app/helpers/forest_liana/adapter_helper.rb
forest_liana-3.0.0.pre.beta.1 app/helpers/forest_liana/adapter_helper.rb
forest_liana-3.0.0.pre.beta.0 app/helpers/forest_liana/adapter_helper.rb
forest_liana-2.14.6 app/helpers/forest_liana/adapter_helper.rb
forest_liana-2.14.5 app/helpers/forest_liana/adapter_helper.rb
forest_liana-2.14.4 app/helpers/forest_liana/adapter_helper.rb
forest_liana-2.14.3 app/helpers/forest_liana/adapter_helper.rb
forest_liana-2.14.2 app/helpers/forest_liana/adapter_helper.rb
forest_liana-2.14.1 app/helpers/forest_liana/adapter_helper.rb
forest_liana-2.14.0 app/helpers/forest_liana/adapter_helper.rb
forest_liana-2.13.7 app/helpers/forest_liana/adapter_helper.rb
forest_liana-2.13.6 app/helpers/forest_liana/adapter_helper.rb
forest_liana-2.13.5 app/helpers/forest_liana/adapter_helper.rb