Merge remote-tracking branch 'origin/cache/harvests' into cache/harvests

This commit is contained in:
Brenda Wallace
2019-12-19 16:55:15 +13:00
5 changed files with 44 additions and 44 deletions

View File

@@ -27,10 +27,10 @@ class PlantingsController < ApplicationController
@plantings = Planting.search(
where: @where,
page: params[:page],
limit: 30,
page: params[:page],
limit: 30,
boost_by: [:created_at],
load: false
load: false
)
@filename = "Growstuff-#{specifics}Plantings-#{Time.zone.now.to_s(:number)}.csv"

View File

@@ -23,18 +23,18 @@ module CropSearch
def search_data
{
name: name,
description: description,
description: description,
slug: slug,
alternate_names: alternate_names.pluck(:name),
scientific_names: scientific_names.pluck(:name),
photos_count: photo_associations_count,
photos_count: photo_associations_count,
# boost the crops that are planted the most
plantings_count: plantings_count,
harvests_count: harvests_count,
harvests_count: harvests_count,
# 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: default_photo&.thumbnail_url,
scientific_name: default_scientific_name&.name,
created_at: created_at.to_i
}

View File

@@ -8,29 +8,29 @@ module HarvestSearch
def search_data
{
slug: slug,
crop_slug: crop.slug,
crop_name: crop.name,
crop_id: crop_id,
plant_part: plant_part&.name,
owner_id: owner_id,
owner_name: owner.login_name,
planting_id: planting_id,
photos_count: photos.size,
has_photos: photos.size.positive?,
slug: slug,
crop_slug: crop.slug,
crop_name: crop.name,
crop_id: crop_id,
plant_part: plant_part&.name,
owner_id: owner_id,
owner_name: owner.login_name,
planting_id: planting_id,
photos_count: photos.size,
has_photos: photos.size.positive?,
thumbnail_url: default_photo&.thumbnail_url,
created_at: created_at.to_i
created_at: created_at.to_i
}
end
def self.homepage_records(limit)
search('*',
limit: limit,
where: {
limit: limit,
where: {
photos_count: { gt: 0 }
},
boost_by: [:created_at],
load: false)
load: false)
end
end
end

View File

@@ -4,16 +4,16 @@ module PhotoSearch
included do
searchkick
scope :search_import, -> { includes(:owner, :crop, :plantings, :harvests, :seeds, P:posts) }
scope :search_import, -> { includes(:owner, :crop, :plantings, :harvests, :seeds, P: posts) }
def search_data
{
slug: slug,
crops: crops.map(&:id),
owner_id: owner_id,
owner_name: owner.login_name,
slug: slug,
crops: crops.map(&:id),
owner_id: owner_id,
owner_name: owner.login_name,
thumbnail_url: thumbnail_url,
created_at: created_at.to_i
created_at: created_at.to_i
}
end
end

View File

@@ -8,32 +8,32 @@ module PlantingSearch
def search_data
{
slug: slug,
crop_slug: crop.slug,
crop_name: crop.name,
crop_id: crop_id,
owner_id: owner_id,
owner_name: owner.login_name,
owner_slug: owner.slug,
planted_from: planted_from,
photos_count: photos.size,
harvests_count: harvests.size,
has_photos: photos.size.positive?,
active: active?,
thumbnail_url: default_photo&.thumbnail_url,
slug: slug,
crop_slug: crop.slug,
crop_name: crop.name,
crop_id: crop_id,
owner_id: owner_id,
owner_name: owner.login_name,
owner_slug: owner.slug,
planted_from: planted_from,
photos_count: photos.size,
harvests_count: harvests.size,
has_photos: photos.size.positive?,
active: active?,
thumbnail_url: default_photo&.thumbnail_url,
percentage_grown: percentage_grown.to_i,
created_at: created_at.to_i
created_at: created_at.to_i
}
end
def self.homepage_records(limit)
search('*',
limit: limit,
where: {
limit: limit,
where: {
photos_count: { gt: 0 }
},
boost_by: [:created_at],
load: false)
load: false)
end
end
end