Files
growstuff/spec
eb427f00de Optimize PaperTrail whodunnit query in CropsController#show (#4796)
* Optimize PaperTrail whodunnit query in CropsController#show

Replace @crop.versions.map(&:whodunnit) with
@crop.versions.distinct.pluck(:whodunnit) to avoid instantiating all PaperTrail version objects and loading object/object_changes into memory.

Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com>

* Optimize PaperTrail whodunnit query in CropsController#show

Replace @crop.versions.map(&:whodunnit) with
@crop.versions.distinct.pluck(:whodunnit) to avoid instantiating all PaperTrail version objects and loading object/object_changes into memory. Added unit test in spec/controllers/crops_controller_spec.rb.

Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com>

* Optimize PaperTrail whodunnit query in CropsController#show

Use @crop.versions.reorder(nil).distinct.pluck(:whodunnit) to avoid instantiating all PaperTrail version objects into memory and prevent PostgreSQL PG::InvalidColumnReference errors with SELECT DISTINCT.

Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com>

* Fix crop route parameter in controller spec

Update parameter key from id to slug in CropsController show spec to match param: :slug route definition.

Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com>

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2026-09-20 13:53:58 +09:30
..
2026-04-24 00:15:18 +09:30
2019-12-26 13:38:17 +13:00
2025-08-10 03:12:58 +00:00
2024-01-07 01:57:19 +00:00