indexed items matching database attributes

This commit is contained in:
Brenda Wallace
2019-12-26 23:15:38 +13:00
parent 5783bb683a
commit e3a789c15e
5 changed files with 8 additions and 4 deletions

View File

@@ -7,7 +7,7 @@ module Finishable
scope :finished, -> { where(finished: true) }
scope :current, -> { where.not(finished: true) }
def active?
def active
!finished
end
end

View File

@@ -15,6 +15,10 @@ module PhotoCapable
end
end
def thumbnail_url
default_photo ? default_photos.thumbnail_url : nil
end
def most_liked_photo
photos.order(likes_count: :desc, created_at: :desc).first
end

View File

@@ -39,7 +39,7 @@ module SearchCrops
# boost this crop for these members
planters_ids: plantings.pluck(:owner_id),
has_photos: photos.size.positive?,
thumbnail_url: default_photo&.thumbnail_url,
thumbnail_url: thumbnail_url,
scientific_name: default_scientific_name&.name,
created_at: created_at.to_i
}

View File

@@ -20,7 +20,7 @@ module SearchPlantings
def search_data
{
slug: slug,
active: active?,
active: active,
crop_id: crop_id,
crop_name: crop.name,
crop_slug: crop.slug,

View File

@@ -1,4 +1,4 @@
- if planting.active? && planting.annual? && planting.percentage_grown.present?
- if planting.active && planting.annual? && planting.percentage_grown.present?
.progress
.progress-bar.bg-success{"aria-valuemax" => "100", "aria-valuemin" => "0", "aria-valuenow" => planting.percentage_grown, role: "progressbar", style: "width: #{planting.percentage_grown}%"}