#73: small refactoring

This commit is contained in:
Vokhmin Alexey V 2013-04-04 01:18:56 +04:00
parent 105e5f54a4
commit 110499360b
1 changed files with 1 additions and 2 deletions

View File

@ -117,9 +117,8 @@ class Projects::PullRequestsController < Projects::BaseController
def autocomplete_to_project def autocomplete_to_project
items = [] items = []
term = params[:term].to_s.strip.downcase term = params[:term].to_s.strip.downcase
condition = ["lower(concat(owner_uname, '/', name)) ILIKE ?", "%#{term}%"]
[Project.accessible_by(current_ability, :membered), @project.ancestors].each do |p| [Project.accessible_by(current_ability, :membered), @project.ancestors].each do |p|
items.concat p.where(condition) items.concat p.where("lower(concat(owner_uname, '/', name)) ILIKE ?", "%#{term}%")
end end
items = items.uniq{|i| i.id}.select{|e| e.repo.branches.count > 0} items = items.uniq{|i| i.id}.select{|e| e.repo.branches.count > 0}
render :json => json_for_autocomplete_base(items) render :json => json_for_autocomplete_base(items)