Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #2952
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!news.mixmin.net!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!talisker.lacave.net!lacave.net!not-for-mail |
|---|---|
| From | "Naina A." <naina.sydney@gmail.com> |
| Newsgroups | comp.lang.ruby |
| Subject | improve query |
| Date | Fri, 15 Apr 2011 11:26:57 -0500 |
| Organization | Service de news de lacave.net |
| Lines | 38 |
| Message-ID | <7151d1a2326fb0eae60078e505bb2fe8@ruby-forum.com> (permalink) |
| NNTP-Posting-Host | bristol.highgroove.com |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | talisker.lacave.net 1302885306 18668 65.111.164.187 (15 Apr 2011 16:35:06 GMT) |
| X-Complaints-To | abuse@lacave.net |
| NNTP-Posting-Date | Fri, 15 Apr 2011 16:35:06 +0000 (UTC) |
| X-Received-From | This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway |
| X-Mail-Count | 381645 |
| X-Ml-Name | ruby-talk |
| X-Rubymirror | Yes |
| X-Ruby-Talk | <7151d1a2326fb0eae60078e505bb2fe8@ruby-forum.com> |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.ruby:2952 |
Show key headers only | View raw
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