Skip to content

Banzai label ref finder - minimize SQL calls by sharing context more aggresively

Mario de la Ossa requested to merge mao/48221-issues_show_sql_count into master

What does this MR do?

When resolving label references inside Banzai, we currently share zero context in-between calls, leading to 10 SQL calls per each label being referenced.

This MR shares the project in the Banzai context a bit more aggressively by

  • Returning the project in the context if the ref matches the project's full path when looking up cross-project refs
  • Adds the ability to send a project object instead of a project ID to the LabelsFinder

These changes bring down the SQL calls per label being referenced from 10 each to 2 each

Please note that cross_project_reference_spec.rb had to be changed because otherwise rspec complained with the following error:

`context` is not available from within an example (e.g. an `it` block) or from constructs that run in the scope of an example (e.g. `before`, `let`, etc). It is only available on an example group (e.g. a `describe` or `context` block).

Work still required

Bringing them down even more will require reworking the way Banzai resolves references - currently we go reference by reference, which makes it hard to share discovered context. If we had an initial "grouping" step where we discover all the references and group them by parent we could then do a single batch operation, which would save a lot of calls. A new issue is being opened for this

What are the relevant issue numbers?

#48221 (closed)

Does this MR meet the acceptance criteria?

Closes #48221 (closed)

Edited by Mario de la Ossa

Merge request reports