### Eclipse Workspace Patch 1.0
#P Redmine
Index: .project
===================================================================
--- .project	(revision 0)
+++ .project	(revision 0)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>Redmine</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+	</buildSpec>
+	<natures>
+	</natures>
+</projectDescription>
Index: app/models/query.rb
===================================================================
--- app/models/query.rb	(revision 2697)
+++ app/models/query.rb	(working copy)
@@ -175,7 +175,12 @@
     if User.current.logged?
       @available_filters["watcher_id"] = { :type => :list, :order => 15, :values => [["<< #{l(:label_me)} >>", "me"]] }
     end
-  
+    
+    @available_filters["relation_blocked_issues"] = { :type => :integer, :order => 51 }
+    @available_filters["relation_blocking_issues"] = { :type => :integer, :order => 52 }
+    @available_filters["relation_preceded_issues"] = { :type => :integer, :order => 53 }
+    @available_filters["relation_preceding_issues"] = { :type => :integer, :order => 54 }
+    
     if project
       # project specific filters
       unless @project.issue_categories.empty?
@@ -365,6 +370,23 @@
         db_field = 'user_id'
         sql << "#{Issue.table_name}.id #{ operator == '=' ? 'IN' : 'NOT IN' } (SELECT #{db_table}.watchable_id FROM #{db_table} WHERE #{db_table}.watchable_type='Issue' AND "
         sql << sql_for_field(field, '=', v, db_table, db_field) + ')'
+      elsif field =~ /^relation_/
+        v = "1" if operator == "*"
+        operator = ">=" if operator == "*"
+        operator = "!*" if operator == "=" && v == 0
+        count_operator = "=" if operator == "="
+        count_operator = ">=" if operator == ">="
+        count_operator = ">" if operator == "<="
+        
+        sql << (operator == ">=" || operator == "=" ? "#{Issue.table_name}.id IN (" : "#{Issue.table_name}.id NOT IN (")
+        sql << (field =~ /ed_issues$/ ? "SELECT ir.issue_to_id" : "SELECT ir.issue_from_id")
+        sql << " FROM issue_relations AS ir"
+        sql << " LEFT OUTER JOIN issues AS i2 ON ir.issue_from_id = i2.id"
+        sql << " LEFT OUTER JOIN issue_statuses AS is2 ON i2.status_id = is2.id"
+        sql << (field =~ /^relation_block/ ? " WHERE ir.relation_type='blocks'" : " WHERE ir.relation_type='precedes'")
+        sql << " AND is2.is_closed = FALSE"
+        sql << " GROUP BY ir.issue_to_id HAVING COUNT(*) #{count_operator} #{v}" unless operator == "!*" 
+        sql << ")"
       else
         # regular field
         db_table = Issue.table_name
Index: config/locales/en.yml
===================================================================
--- config/locales/en.yml	(revision 2697)
+++ config/locales/en.yml	(working copy)
@@ -243,6 +243,10 @@
   field_identity_url: OpenID URL
   field_content: Content
   field_group_by: Group results by
+  field_relation_blocked_issues: Blocked by open issues
+  field_relation_blocking_issues: Blocking other issues
+  field_relation_preceded_issues: Preceded by open issues
+  field_relation_preceding_issues: Preceding other issues
   
   setting_app_title: Application title
   setting_app_subtitle: Application subtitle
