[#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
|
||||
@issues = []
|
||||
q = params[:q].to_s
|
||||
query = (params[:scope] == "all" && Setting.cross_project_issue_relations?) ? Issue : @project.issues
|
||||
if q.match(/^\d+$/)
|
||||
@issues << query.visible.find_by_id(q.to_i)
|
||||
end
|
||||
unless q.blank?
|
||||
@issues += query.visible.find(:all,
|
||||
|
||||
if q.present?
|
||||
query = (params[:scope] == "all" && Setting.cross_project_issue_relations?) ? Issue : @project.issues
|
||||
|
||||
@issues |= query.visible.find_all_by_id(q.to_i) if q =~ /^\d+$/
|
||||
|
||||
@issues |= query.visible.find(:all,
|
||||
:limit => 10,
|
||||
: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}%" }])
|
||||
end
|
||||
@issues.compact!
|
||||
@issues.uniq!
|
||||
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue