fix query_patch for impediments: having a closing bracket now and excluding issues with parent_id

pull/6827/head
Jens Ulferts 14 years ago
parent 98ec5ac146
commit b5ede9aee1
  1. 35
      lib/backlogs_query_patch.rb

@ -39,36 +39,36 @@ module Backlogs
], ],
:default_order => 'asc')) :default_order => 'asc'))
alias_method_chain :available_filters, :backlogs_issue_type alias_method_chain :available_filters, :backlogs_issue_type
alias_method_chain :sql_for_field, :backlogs_issue_type alias_method_chain :sql_for_field, :backlogs_issue_type
end end
end end
module InstanceMethods module InstanceMethods
def available_filters_with_backlogs_issue_type def available_filters_with_backlogs_issue_type
@available_filters = available_filters_without_backlogs_issue_type @available_filters = available_filters_without_backlogs_issue_type
if Story.trackers.length == 0 or Task.tracker.blank? if Story.trackers.length == 0 or Task.tracker.blank?
backlogs_filters = { } backlogs_filters = { }
else else
backlogs_filters = { backlogs_filters = {
"backlogs_issue_type" => { :type => :list, "backlogs_issue_type" => { :type => :list,
:values => [[l(:backlogs_story), "story"], [l(:backlogs_task), "task"], [l(:backlogs_impediment), "impediment"], [l(:backlogs_any), "any"]], :values => [[l(:backlogs_story), "story"], [l(:backlogs_task), "task"], [l(:backlogs_impediment), "impediment"], [l(:backlogs_any), "any"]],
:order => 20 } :order => 20 }
} }
end end
return @available_filters.merge(backlogs_filters) return @available_filters.merge(backlogs_filters)
end end
def sql_for_field_with_backlogs_issue_type(field, operator, v, db_table, db_field, is_custom_filter=false) def sql_for_field_with_backlogs_issue_type(field, operator, v, db_table, db_field, is_custom_filter=false)
if field == "backlogs_issue_type" if field == "backlogs_issue_type"
db_table = Issue.table_name db_table = Issue.table_name
sql = [] sql = []
selected_values = values_for(field) selected_values = values_for(field)
selected_values = ['story', 'task'] if selected_values.include?('any') selected_values = ['story', 'task'] if selected_values.include?('any')
@ -85,36 +85,37 @@ module Backlogs
sql << "(#{db_table}.id in ( sql << "(#{db_table}.id in (
select issue_from_id select issue_from_id
from issue_relations ir from issue_relations ir
join issues blocked on join issues blocked
on
blocked.id = ir.issue_to_id blocked.id = ir.issue_to_id
and blocked.tracker_id in (#{all_trackers}) and blocked.tracker_id in (#{all_trackers})
where ir.relation_type = 'blocks' where ir.relation_type = 'blocks'
)" ) and #{db_table}.parent_id is NULL)"
end end
} }
case operator case operator
when "=" when "="
sql = sql.join(" or ") sql = sql.join(" or ")
when "!" when "!"
sql = "not (" + sql.join(" or ") + ")" sql = "not (" + sql.join(" or ") + ")"
end end
return sql return sql
else else
return sql_for_field_without_backlogs_issue_type(field, operator, v, db_table, db_field, is_custom_filter) return sql_for_field_without_backlogs_issue_type(field, operator, v, db_table, db_field, is_custom_filter)
end end
end end
end end
module ClassMethods module ClassMethods
# Setter for +available_columns+ that isn't provided by the core. # Setter for +available_columns+ that isn't provided by the core.
def available_columns=(v) def available_columns=(v)
self.available_columns = (v) self.available_columns = (v)
end end
# Method to add a column to the +available_columns+ that isn't provided by the core. # Method to add a column to the +available_columns+ that isn't provided by the core.
def add_available_column(column) def add_available_column(column)
self.available_columns << (column) self.available_columns << (column)

Loading…
Cancel
Save