Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #2952
| From | "Naina A." <naina.sydney@gmail.com> |
|---|---|
| Newsgroups | comp.lang.ruby |
| Subject | improve query |
| Date | 2011-04-15 11:26 -0500 |
| Organization | Service de news de lacave.net |
| Message-ID | <7151d1a2326fb0eae60078e505bb2fe8@ruby-forum.com> (permalink) |
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
--
Posted via http://www.ruby-forum.com/.
Back to comp.lang.ruby | Previous | Next — Next in thread | Find similar | Unroll thread
improve query "Naina A." <naina.sydney@gmail.com> - 2011-04-15 11:26 -0500 Re: improve query "Naina A." <naina.sydney@gmail.com> - 2011-04-15 11:57 -0500
csiph-web