diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /app/models/issue | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
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 |