diff --git a/app/models/concerns/photo_capable.rb b/app/models/concerns/photo_capable.rb index 9cb440bd7..f96258f87 100644 --- a/app/models/concerns/photo_capable.rb +++ b/app/models/concerns/photo_capable.rb @@ -8,7 +8,9 @@ module PhotoCapable scope :has_photos, -> { includes(:photos).where.not(photos: { id: nil }) } def default_photo - most_liked_photo + Rails.cache.fetch("#{cache_key_with_version}/default_photo", expires_in: 8.hours) do + most_liked_photo + end end def most_liked_photo diff --git a/app/models/concerns/predict_planting.rb b/app/models/concerns/predict_planting.rb index e02fe5e5b..b43a70149 100644 --- a/app/models/concerns/predict_planting.rb +++ b/app/models/concerns/predict_planting.rb @@ -42,14 +42,16 @@ module PredictPlanting end def percentage_grown - if finished? - 100 - elsif !planted? - 0 - elsif crop.perennial || finish_predicted_at.nil? - nil - else - calculate_percentage_grown + Rails.cache.fetch("#{cache_key_with_version}/percentage_grown", expires_in: 8.hours) do + if finished? + 100 + elsif !planted? + 0 + elsif crop.perennial || finish_predicted_at.nil? + nil + else + calculate_percentage_grown + end end end