添加为空判断

This commit is contained in:
huang 2015-09-03 17:15:38 +08:00
parent f1431b27fc
commit dd06aa3a92
1 changed files with 18 additions and 16 deletions

View File

@ -492,25 +492,27 @@ class Query < ActiveRecord::Base
def project_statement
project_clauses = []
if project && !project.descendants.active.empty?
ids = [project.id]
if has_filter?("subproject_id")
case operator_for("subproject_id")
when '='
# include the selected subprojects
ids += values_for("subproject_id").each(&:to_i)
when '!*'
# main project only
else
# all subprojects
unless project.descendants.blank?
if project && !project.descendants.active.empty?
ids = [project.id]
if has_filter?("subproject_id")
case operator_for("subproject_id")
when '='
# include the selected subprojects
ids += values_for("subproject_id").each(&:to_i)
when '!*'
# main project only
else
# all subprojects
ids += project.descendants.collect(&:id)
end
elsif Setting.display_subprojects_issues?
ids += project.descendants.collect(&:id)
end
elsif Setting.display_subprojects_issues?
ids += project.descendants.collect(&:id)
project_clauses << "#{Project.table_name}.id IN (%s)" % ids.join(',')
elsif project
project_clauses << "#{Project.table_name}.id = %d" % project.id
end
project_clauses << "#{Project.table_name}.id IN (%s)" % ids.join(',')
elsif project
project_clauses << "#{Project.table_name}.id = %d" % project.id
end
project_clauses.any? ? project_clauses.join(' AND ') : nil
end