Skip to content

Instantly share code, notes, and snippets.

@tenpaiyomi
Created October 14, 2015 13:41
Show Gist options
  • Save tenpaiyomi/ee0a76faa69aa428592f to your computer and use it in GitHub Desktop.
Save tenpaiyomi/ee0a76faa69aa428592f to your computer and use it in GitHub Desktop.
# Main search function
def self.search(params, location)
perform_search(location, params[:activity], params[:start_time], params[:end_time])
end
def self.by_activity(activity)
perform_search("Ottawa,ON", activity, nil, nil)
end
protected
def perform_search(location, activity, start_time, end_time)
self
.join
.not_booked
.after_now
.close_to(Venue.close_to(location))
.activity(Activity.find_by_name activity.titlecase)
.start_date(validate_start_time start_time)
.end_date(validate_end_time end_time)
.sorted
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment