175 |
175 |
if User.current.logged?
|
176 |
176 |
@available_filters["watcher_id"] = { :type => :list, :order => 15, :values => [["<< #{l(:label_me)} >>", "me"]] }
|
177 |
177 |
end
|
178 |
|
|
|
178 |
|
|
179 |
@available_filters["relation_blocked_issues"] = { :type => :integer, :order => 51 }
|
|
180 |
@available_filters["relation_blocking_issues"] = { :type => :integer, :order => 52 }
|
|
181 |
@available_filters["relation_preceded_issues"] = { :type => :integer, :order => 53 }
|
|
182 |
@available_filters["relation_preceding_issues"] = { :type => :integer, :order => 54 }
|
|
183 |
|
179 |
184 |
if project
|
180 |
185 |
# project specific filters
|
181 |
186 |
unless @project.issue_categories.empty?
|
... | ... | |
365 |
370 |
db_field = 'user_id'
|
366 |
371 |
sql << "#{Issue.table_name}.id #{ operator == '=' ? 'IN' : 'NOT IN' } (SELECT #{db_table}.watchable_id FROM #{db_table} WHERE #{db_table}.watchable_type='Issue' AND "
|
367 |
372 |
sql << sql_for_field(field, '=', v, db_table, db_field) + ')'
|
|
373 |
elsif field =~ /^relation_/
|
|
374 |
v = "1" if operator == "*"
|
|
375 |
operator = ">=" if operator == "*"
|
|
376 |
operator = "!*" if operator == "=" && v == 0
|
|
377 |
count_operator = "=" if operator == "="
|
|
378 |
count_operator = ">=" if operator == ">="
|
|
379 |
count_operator = ">" if operator == "<="
|
|
380 |
|
|
381 |
sql << (operator == ">=" || operator == "=" ? "#{Issue.table_name}.id IN (" : "#{Issue.table_name}.id NOT IN (")
|
|
382 |
sql << (field =~ /ed_issues$/ ? "SELECT ir.issue_to_id" : "SELECT ir.issue_from_id")
|
|
383 |
sql << " FROM issue_relations AS ir"
|
|
384 |
sql << " LEFT OUTER JOIN issues AS i2 ON ir.issue_from_id = i2.id"
|
|
385 |
sql << " LEFT OUTER JOIN issue_statuses AS is2 ON i2.status_id = is2.id"
|
|
386 |
sql << (field =~ /^relation_block/ ? " WHERE ir.relation_type='blocks'" : " WHERE ir.relation_type='precedes'")
|
|
387 |
sql << " AND is2.is_closed = FALSE"
|
|
388 |
sql << " GROUP BY ir.issue_to_id HAVING COUNT(*) #{count_operator} #{v}" unless operator == "!*"
|
|
389 |
sql << ")"
|
368 |
390 |
else
|
369 |
391 |
# regular field
|
370 |
392 |
db_table = Issue.table_name
|