diff options
Diffstat (limited to 'app/models/issue')
-rw-r--r-- | app/models/issue/metrics.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/app/models/issue/metrics.rb b/app/models/issue/metrics.rb index a5e1957c096..86523bbd023 100644 --- a/app/models/issue/metrics.rb +++ b/app/models/issue/metrics.rb @@ -24,6 +24,10 @@ class Issue::Metrics < ApplicationRecord private def issue_assigned_to_list_label? - issue.labels.any? { |label| label.lists.present? } + # Avoid another DB lookup when issue.labels are empty by adding a guard clause here + # We can't use issue.labels.empty? because that will cause a `Label Exists?` DB lookup + return false if issue.labels.length == 0 # rubocop:disable Style/ZeroLengthPredicate + + issue.labels.includes(:lists).any? { |label| label.lists.present? } end end |