mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-10 16:54:38 -04:00
This commit introduces memoization to various methods in the Planting model, PredictPlanting and PredictHarvest concerns, PlantingsHelper, and PlantingsController. Specifically: - Memoized database-intensive lookups like `nearby_same_crop`, `first_harvest_date`, and `last_harvest_date`. - Memoized calculated fields like `finish_predicted_at`, `expected_lifespan`, and `age_in_days`. - Optimized `PlantingsHelper#transplantable_gardens_by_owner` using a hash to cache results per planting instance within a request. - Applied the `defined?(@variable)` pattern where appropriate to ensure efficient handling of `nil` results. These changes reduce redundant database queries and expensive calculations, particularly during view rendering where these methods are frequently accessed. Co-authored-by: CloCkWeRX <365751+CloCkWeRX@users.noreply.github.com>