app/models/dataset_setting.rb
def filters_sql
    if filters.blank?
      ''
    else
      conditions = JSON.parse filters
      sql_array = []
      conditions.each do |condition|
        if condition['values']
          values = condition['values'].map { |x| "'#{x}'" }.join(',')
          sql_array << " #{condition['name']} in (#{values})"
        else
          sql_array << " #{condition['name']} between #{condition['from']} and #{condition['to']}"
        end
      end
      sql_array.join(' AND ')
    end
  end
# Returns the WHERE part of the sql query (the filters)
Returns the WHERE part of the sql query (the filters)
Returns the WHERE part of the sql query ( the filters )
def filters_sql
    if filters.blank?
      ''
    else
      conditions = JSON.parse filters
      sql_array = []
      conditions.each do |condition|
        if condition['values']
          values = condition['values'].map { |x| "'#{x}'" }.join(',')
          sql_array << " #{condition['name']} in (#{values})"
        else
          sql_array << " #{condition['name']} between #{condition['from']} and #{condition['to']}"
        end
      end
      sql_array.join(' AND ')
    end
  end
def filters_sql if filters . blank? '' else conditions = JSON . parse filters sql_array = [ ] conditions . each do | condition | if condition [ 'values' ] values = condition [ 'values' ] . map { | x | "'#{x}'" } . join ( ',' ) sql_array << " #{condition['name']} in (#{values})" else sql_array << " #{condition['name']} between #{condition['from']} and #{condition['to']}" end end sql_array . join ( ' AND ' ) end end
Returns the WHERE part of the sql query (the filters)
Returns the WHERE part of the sql query ( the filters )