Skip to content

Instantly share code, notes, and snippets.

@felipero
Created March 24, 2010 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felipero/342700 to your computer and use it in GitHub Desktop.
Save felipero/342700 to your computer and use it in GitHub Desktop.
def self.get_top_picks(domain, type, category, level, page = 1)
results = SearchableListing.category(category.id, level).by_type(type).
domain(domain.id).lookup_page(page).
rating_no_less_than(0).star_rating_no_less_than(3).
lvs_not_null.one_per_user_highest_lvs.with_photos.
top_picks_with_join
ids = results.collect(&:listing_id).uniq
results = Listing.find(ids, :order => ids.to_id_sql_order, :include => :user)
results.reject! { |l| l.get_availability == AdvisorStatus::Status::AWAY || l.user.busy_on_call? }
return results.size > ITEMS_PER_PAGE, results[0...ITEMS_PER_PAGE] || []
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment