diff --git a/app/models/issue.rb b/app/models/issue.rb index 95e5a4f24..cfad63a91 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -1018,7 +1018,9 @@ class Issue < ApplicationRecord # Returns true if this issue is blocked by another issue that is still open def blocked? - !relations_to.detect {|ir| ir.relation_type == 'blocks' && !ir.issue_from.closed?}.nil? + return false if relations.empty? + + relations_to.where(relation_type: IssueRelation::TYPE_BLOCKS).any? {|ir| !ir.issue_to.closed?} end # Returns true if this issue can be closed and if not, returns false and populates the reason @@ -1348,7 +1350,9 @@ class Issue < ApplicationRecord # Returns an array of issues that duplicate this one def duplicates - relations_to.select {|r| r.relation_type == IssueRelation::TYPE_DUPLICATES}.collect {|r| r.issue_from} + return [] if relations.empty? + + relations_to.where(relation_type: IssueRelation::TYPE_DUPLICATES).collect(&:issue_from) end # Returns the due date or the target due date if any