-
-
Save ziyadbasheer/d9276d9cc8b45791caa0 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
if params[:name] == nil | |
if params[:date] | |
if params[:length] | |
@programs = Program.where("startdate between ? and ?", @chosendate.weeks_ago(2), @chosendate.weeks_since(2)).where("minlength between ? and ?", @chosenlength - 2, @chosenlength + 2) | |
@happens = 'by date and length' | |
else | |
@programs = Program.where("startdate between ? and ?", @chosendate.weeks_ago(2), @chosendate.weeks_since(2)) | |
@happens = 'by date' | |
end | |
else | |
@programs = Program.where("minlength between ? and ?", @chosenlength - 2, @chosenlength + 2) | |
@happens = 'by length' | |
end | |
elsif params[:date] == nil | |
if params[:name] | |
if params[:length] | |
@programs = Program.where("name LIKE ? OR description LIKE ?", params[:name], params[:name]).where("minlength between ? and ?", @chosenlength - 2, @chosenlength + 2) | |
@happens = 'by name and length' | |
else | |
@programs = Program.where("name LIKE ? OR description LIKE ?", params[:name], params[:name]) | |
@happens = 'by name' | |
end | |
else | |
@programs = Program.where("minlength between ? and ?", @chosenlength - 2, @chosenlength + 2) | |
@happens = 'by length' | |
end | |
elsif params[:length] == nil | |
if params[:name] | |
if params[:date] | |
@programs = Program.where("name LIKE ? OR description LIKE ?", params[:name], params[:name]).where("startdate between ? and ?", @chosendate.weeks_ago(2), @chosendate.weeks_since(2)) | |
@happens = 'by name and date' | |
else | |
@programs = Program.where("name LIKE ? OR description LIKE ?", params[:name], params[:name]) | |
@happens = 'by name' | |
end | |
else | |
@programs = Program.where("startdate between ? and ?", @chosendate.weeks_ago(2), @chosendate.weeks_since(2)) | |
@happens = 'by date' | |
end | |
else | |
@programs = Program.where("name LIKE ? OR description LIKE ?", params[:name], params[:name]).where("startdate between ? and ?", @chosendate.weeks_ago(2), @chosendate.weeks_since(2)).where("minlength between ? and ?", @chosenlength - 2, @chosenlength + 2) | |
@happens = 'by all' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment