Created
May 30, 2013 02:32
-
-
Save JKring/5675407 to your computer and use it in GitHub Desktop.
long query
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
query = {:per_page=>15, :page=>1, :blacklisted=>false, :not_team_ids=>["5090770bd6841267b10004b4"], :search_terms=>nil, :sort=>[:team_scores_5090770bd6841267b10004b4_num_overall, :desc]} | |
solrquery = Writer.search do | |
all_of do | |
without(:removed).equal_to(true) | |
without(:blacklisted).equal_to(true) if query[:blacklisted] == false | |
with(:has_photo).equal_to(true) if query[:has_photo] | |
with(:team_ids).any_of(query[:team_ids]) if query[:team_ids] | |
without(:team_ids).any_of(query[:not_team_ids]) if query[:not_team_ids] | |
with(:group_ids).any_of([query[:group_ids]]) if query[:group_ids] | |
end | |
if query[:search_terms].blank? | |
order_by(query[:sort][0], query[:sort][1]) | |
else | |
fulltext query[:search_terms] | |
end | |
paginate(:page => query[:page], :per_page => query[:per_page]) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment