Created
August 25, 2008 06:11
-
-
Save HamptonMakes/7032 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.query(query) | |
if @parser.nil? | |
@parser = Searcher::Parser.new | |
@parser.lookup(:academic_field, "academic_fields.name") | |
@parser.lookup(:sat_1600, "(sat_1600_math_score + sat_1600_verbal_score)") | |
@parser.lookup(:sat_2400, "(sat_2400_math_score + sat_2400_critical_reading_score + sat_2400_writing_score)") | |
@parser.lookup(:act, "(act_english_score + act_math_score + act_reading_score + act_science_reasoning_score)") | |
@parser.lookup(:job_type, "job_types.name") | |
@parser.lookup(:field_of_interest, "field_of_interests.name") | |
@parser.lookup(:location) do |value| | |
location = PreferredLocation.find_by_name(value) | |
tolerance = 1 | |
["((preferred_locations.lat between ? and ?) AND (preferred_locations.lon between ? and ?))", location.lat - tolerance, location.lat + tolerance, location.lon - tolerance, location.lon + tolerance] | |
end | |
end | |
self.find(:all, :conditions => @parser.parse(query), :include => [:academic_fields, {:job_types => :field_of_interest}, :preferred_locations]) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment