paper_trail icon indicating copy to clipboard operation
paper_trail copied to clipboard

Fix: n+1 when loading a changeset

Open HashNotAdam opened this issue 2 years ago • 1 comments

When producing a changeset, the item is loaded from the database in order to check it's class. This came about because of issues that emerged when supporting STI.

Unfortunately, the result is that the record is retrieved once for every version despite the fact that the item class will be the same.

The documented reason for moving away from using item_type to know the class was that it returns the wrong class when working with STI but there is an item_subtype which returns the correct class.

Check the following boxes:

  • [x] Wrote [good commit messages][1].
  • [x] Feature branch is up-to-date with master (if not - rebase it).
  • [N/A] Squashed related commits together.
  • [N/A] Added tests.
  • [N/A] Added an entry to the Changelog if the new code introduces user-observable changes.
  • [x] The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.

HashNotAdam avatar Mar 31 '22 05:03 HashNotAdam