docbrown/app
Jeremy Friesen be97f2fc07
Favoring dependent: :delete_all over :destroy (#15442)
* Favoring dependent: :delete_all over :destroy

The `dependent: :destroy` callback is slower than `dependent: :delete`
and `dependent: :delete_all`.  We need only favor the `dependent:
:destroy` when there's callbacks that happen.

In the case of :destroy, ActiveRecord instantiates each object and then
runs destroy.  Whereas in the case of :delete, ActiveRecord issues a SQL
command to delete the related files.

It is often "safer" to use :destroy, as it guarantees that you'll
instantiate the record and run it's callbacks.  But sometimes you have
to go with the speed of SQL.

This relates to #14140.  Note there is still more to consider, but given
that we're looking at moving from :destroy on all of an article's page
views to :delete, we might buy enough time in the callback.

* Removing redundancy of article destroy

Prior to this commit, `before_destroy_actions` called the `bust_cache`
method which in turn called `touch_actor_latest_article_updated_at` but
`bust_cache` did not pass the destroying parameter.  Then
`before_destroy_actions` immediately called
`touch_actor_latest_article_updated_at` with `destroying: true`.

With this change, we remove one of those duplicate calls.

* Fixing specs regarding relationships

* Fixing specs regarding relationships
2021-11-24 13:56:16 -05:00
..
assets Preventing author profile from going transparent (#15478) 2021-11-24 09:38:13 -05:00
black_box Make Rubocop happy again (#14729) 2021-09-14 09:15:01 -05:00
components/admin/users Small change to make the tools section of member details mobile friendly. (#15159) 2021-10-22 18:47:20 +02:00
controllers ForemMobile namespaced functions (#15212) 2021-11-23 15:25:29 -06:00
decorators Theming cleanup (#15237) 2021-11-09 10:11:55 -05:00
errors Guarding against spam from OAuth Sources (#15404) 2021-11-18 16:26:39 -05:00
helpers Enable Forem (Passport) Auth (#15141) 2021-11-23 14:59:00 -06:00
javascript Preventing author profile from going transparent (#15478) 2021-11-24 09:38:13 -05:00
lib ✂✂✂ Remove Connect (#14734) 2021-11-18 08:21:00 -06:00
liquid_tags complete changes (#15420) 2021-11-18 14:19:45 -05:00
mailers ✂✂✂ Remove Connect (#14734) 2021-11-18 08:21:00 -06:00
models Favoring dependent: :delete_all over :destroy (#15442) 2021-11-24 13:56:16 -05:00
policies ✂✂✂ Remove Connect (#14734) 2021-11-18 08:21:00 -06:00
queries Adds validations to avoid creating unnecessary PNs (#14621) 2021-08-31 15:00:30 -06:00
refinements
sanitizers Remove redundant freeze calls (#14596) 2021-08-26 10:01:08 -04:00
serializers ✂✂✂ Remove Connect (#14734) 2021-11-18 08:21:00 -06:00
services Ensuring reading list excludes unpublished articles (#15490) 2021-11-24 13:22:26 -05:00
uploaders ✂✂✂ Remove events (#15062) 2021-10-15 09:31:08 -04:00
validators Updating valid domain registration (#15436) 2021-11-19 10:05:00 -05:00
view_objects Upgrade to Ruby 3.0.2 (#12103) 2021-08-25 14:26:33 -04:00
views Preventing author profile from going transparent (#15478) 2021-11-24 09:38:13 -05:00
workers Guarding against missing experiments (#15440) 2021-11-22 16:06:32 -05:00