mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-04 03:30:38 +08:00
When fetching a model using the `model` step in a service, if that model is an `ActiveRecord` object, we check if it’s in a valid state. While this is useful when manipulating the model or when we create a new one, it’s not the case for a model we just pulled from the DB, as it should be valid. In some cases, running the validations can be costly (it can lead to N+1 queries if the model validates associated items for example). This patch introduces a small optimization by checking if the model has any pending changes on it, thus requiring validation. If that’s not the case, we just skip the validation part, as the model should be valid anyway. |
||
|---|---|---|
| .. | ||
| runner_spec.rb | ||
| steps_inspector_spec.rb | ||