mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-02-02 13:41:00 -05:00
Load planting rss from elastic too
This commit is contained in:
@@ -5,11 +5,11 @@ module PlantingSearch
|
||||
|
||||
included do
|
||||
searchkick merge_mappings: true,
|
||||
mappings: {
|
||||
mappings: {
|
||||
properties: {
|
||||
created_at: { type: :integer },
|
||||
created_at: { type: :integer },
|
||||
harvests_count: { type: :integer },
|
||||
photos_count: { type: :integer },
|
||||
photos_count: { type: :integer },
|
||||
owner_location: { type: :text }
|
||||
}
|
||||
}
|
||||
@@ -18,34 +18,38 @@ 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?,
|
||||
finished: finished?,
|
||||
thumbnail_url: default_photo&.thumbnail_url,
|
||||
owner_location: owner.location,
|
||||
slug: slug,
|
||||
active: active?,
|
||||
crop_id: crop_id,
|
||||
crop_name: crop.name,
|
||||
crop_slug: crop.slug,
|
||||
finished: finished?,
|
||||
harvests_count: harvests.size,
|
||||
has_photos: photos.size.positive?,
|
||||
location: location,
|
||||
owner_id: owner_id,
|
||||
owner_location: owner.location,
|
||||
owner_name: owner.login_name,
|
||||
owner_slug: owner.slug,
|
||||
percentage_grown: percentage_grown.to_i,
|
||||
created_at: created_at.to_i
|
||||
photos_count: photos.size,
|
||||
planted_at: planted_at,
|
||||
planted_from: planted_from,
|
||||
quantity: quantity,
|
||||
sunniness: sunniness,
|
||||
thumbnail_url: default_photo&.thumbnail_url,
|
||||
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
|
||||
|
||||
@@ -6,15 +6,15 @@
|
||||
%link= plantings_url
|
||||
- @plantings.each do |planting|
|
||||
%item
|
||||
%title #{planting.crop} in #{planting.location}
|
||||
%pubdate= planting.created_at.to_s(:rfc822)
|
||||
%title #{planting['crop']} in #{planting['location']}
|
||||
%pubdate= planting['created_at'].to_s(:rfc822)
|
||||
%description
|
||||
:escaped
|
||||
<p>Quantity: #{planting.quantity ? planting.quantity : 'unknown' }</p>
|
||||
<p>Planted on: #{planting.planted_at ? planting.planted_at : 'unknown' }</p>
|
||||
<p>Sunniness: #{planting.sunniness ? planting.sunniness : 'unknown' }</p>
|
||||
<p>Planted from: #{planting.planted_from ? planting.planted_from : 'unknown' }</p>
|
||||
<p>Quantity: #{planting['quantity'] ? planting['quantity'] : 'unknown' }</p>
|
||||
<p>Planted on: #{planting['planted_at'] ? planting['planted_at'] : 'unknown' }</p>
|
||||
<p>Sunniness: #{planting['sunniness'] ? planting['sunniness'] : 'unknown' }</p>
|
||||
<p>Planted from: #{planting['planted_from'] ? planting['planted_from'] : 'unknown' }</p>
|
||||
:escaped_markdown
|
||||
#{ strip_tags planting.description }
|
||||
%link= planting_url(planting)
|
||||
%guid= planting_url(planting)
|
||||
#{ strip_tags planting['description'] }
|
||||
%link= planting_url(slug: planting['slug'])
|
||||
%guid= planting_url(slug: planting['slug'])
|
||||
|
||||
Reference in New Issue
Block a user