diff options
author | Paco Guzman <pacoguzmanp@gmail.com> | 2016-09-27 17:13:20 +0200 |
---|---|---|
committer | Paco Guzman <pacoguzmanp@gmail.com> | 2016-09-28 09:08:28 +0200 |
commit | f4a84f504f2119a32a6c8909dc72680a191d7174 (patch) | |
tree | 05566ac2864238eb4edb091a9aad88839ba840fc | |
parent | 684baf7e7e8f7263bba6cccb7457bbc242135484 (diff) | |
download | gitlab-ce-f4a84f504f2119a32a6c8909dc72680a191d7174.tar.gz |
Avoid database queries on Banzai::ReferenceParser::BaseParser for nodes without references22681-avoid-empty-queries-on-reference-parsers
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | lib/banzai/reference_parser/base_parser.rb | 6 |
2 files changed, 6 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG index df93f89a41a..8e75ef4214b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,7 @@ v 8.13.0 (unreleased) - Speed-up group milestones show page - Log LDAP lookup errors and don't swallow unrelated exceptions. !6103 (Markus Koller) - Add more tests for calendar contribution (ClemMakesApps) + - Avoid database queries on Banzai::ReferenceParser::BaseParser for nodes without references - Fix robots.txt disallowing access to groups starting with "s" (Matt Harrison) - Only update issuable labels if they have been changed - Revoke button in Applications Settings underlines on hover. diff --git a/lib/banzai/reference_parser/base_parser.rb b/lib/banzai/reference_parser/base_parser.rb index e8e03e4a98f..f5d110e987b 100644 --- a/lib/banzai/reference_parser/base_parser.rb +++ b/lib/banzai/reference_parser/base_parser.rb @@ -79,7 +79,11 @@ module Banzai def referenced_by(nodes) ids = unique_attribute_values(nodes, self.class.data_attribute) - references_relation.where(id: ids) + if ids.empty? + references_relation.none + else + references_relation.where(id: ids) + end end # Returns the ActiveRecord::Relation to use for querying references in the |