Compare IDs instead of model instances when possible.
Review Request #10380 — Created Jan. 13, 2019 and submitted — Latest diff uploaded
We had several regularly-invoked model instance comparisons in the
product that could result in unwanted database queries. These were
usually found in accessibility checks, comparing if a requesting user
matches the user owning an object.To reduce overhead, we now compare the IDs, which is faster even if the
instances were already loaded. This cuts down on a number of queries in
common usage.Test coverage for these checks have been improved, with many
accessibility checks that were previously covered implicitly through
other test suites now having explicit test coverage.There's also a fix for a bad permission name, which impacted the tests.
Thecan_edit_status
permission forStatusUpdate
needed to be
change_statusupdate
.
Unit tests pass.