[#373] Refactoring auto_completes#issues action
hoping to make it more intention revealing
This commit is contained in:
parent
8509212991
commit
dbd6dfc69b
|
@ -4,18 +4,18 @@ class AutoCompletesController < ApplicationController
|
||||||
def issues
|
def issues
|
||||||
@issues = []
|
@issues = []
|
||||||
q = params[:q].to_s
|
q = params[:q].to_s
|
||||||
query = (params[:scope] == "all" && Setting.cross_project_issue_relations?) ? Issue : @project.issues
|
|
||||||
if q.match(/^\d+$/)
|
if q.present?
|
||||||
@issues << query.visible.find_by_id(q.to_i)
|
query = (params[:scope] == "all" && Setting.cross_project_issue_relations?) ? Issue : @project.issues
|
||||||
end
|
|
||||||
unless q.blank?
|
@issues |= query.visible.find_all_by_id(q.to_i) if q =~ /^\d+$/
|
||||||
@issues += query.visible.find(:all,
|
|
||||||
|
@issues |= query.visible.find(:all,
|
||||||
:limit => 10,
|
:limit => 10,
|
||||||
:order => "#{Issue.table_name}.id ASC",
|
:order => "#{Issue.table_name}.id ASC",
|
||||||
:conditions => ["LOWER(#{Issue.table_name}.subject) LIKE :q OR CAST(#{Issue.table_name}.id AS CHAR(13)) LIKE :q", {:q => "%#{q.downcase}%" }])
|
:conditions => ["LOWER(#{Issue.table_name}.subject) LIKE :q OR CAST(#{Issue.table_name}.id AS CHAR(13)) LIKE :q", {:q => "%#{q.downcase}%" }])
|
||||||
end
|
end
|
||||||
@issues.compact!
|
|
||||||
@issues.uniq!
|
|
||||||
render :layout => false
|
render :layout => false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue