N
Naina A.
Hi, I am trying to improve the quality of the query inside Ruby. This
below query is giving very long output. Can anyone please let me know if
there a way to use cache instead of retrieving them every time from the
database?
@queries.each_pair do |field_name, value_array|
if ( check_for_symbols )
force_to_symbol = []
keep_as_requested = []
value_array.each do | value |
the_symbols = get_symbol(nil, value.strip.upcase.gsub(/\"/,
''), true)
if ( !the_symbols.nil?)
the_symbols.each { | the_symbol | force_to_symbol <<
the_symbol[:symbol]}
else
keep_as_requested << value
end
end
if ( keep_as_requested.length > 0 )
query_string << (joiner + field_name.to_s + '' +
keep_as_requested.join(' OR ') + ') ')
joiner = 'OR '
end
if ( force_to_symbol.length > 0 )
query_string << (joiner + :symbol.to_s + '' +
force_to_symbol.join(' OR ') + ') ')
end
else
query_string << (joiner + field_name.to_s + '' +
value_array.join(' OR ') + ') ')
end
joiner = 'OR '
end
below query is giving very long output. Can anyone please let me know if
there a way to use cache instead of retrieving them every time from the
database?
@queries.each_pair do |field_name, value_array|
if ( check_for_symbols )
force_to_symbol = []
keep_as_requested = []
value_array.each do | value |
the_symbols = get_symbol(nil, value.strip.upcase.gsub(/\"/,
''), true)
if ( !the_symbols.nil?)
the_symbols.each { | the_symbol | force_to_symbol <<
the_symbol[:symbol]}
else
keep_as_requested << value
end
end
if ( keep_as_requested.length > 0 )
query_string << (joiner + field_name.to_s + '' +
keep_as_requested.join(' OR ') + ') ')
joiner = 'OR '
end
if ( force_to_symbol.length > 0 )
query_string << (joiner + :symbol.to_s + '' +
force_to_symbol.join(' OR ') + ') ')
end
else
query_string << (joiner + field_name.to_s + '' +
value_array.join(' OR ') + ') ')
end
joiner = 'OR '
end