IssueReferenceFilter runs queries for every issue reference in a document
This is mostly due to object_link_filter
in AbstractReferenceFilter
calling find_object
in the following loop:
references_in(text, pattern) do |match, id, project_ref, matches|
...
end
While there is find_object_cached
this only caches an object after it's found and is mostly useful when rendering multiple documents containing the same references (so they can re-use the same object). The proper solution is to do two passes:
- A pass in which we find all references and then get the issues per project using 1 query per project
- A pass where we render the links, re-using the data gathered in step 1
This means that if you have a number of issues belonging to 5 different projects we'd still run 5 queries, but at least it's no longer directly tied into the number of references. Since cross project references are less likely to appear this should at least be a good start.