mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-02-02 13:41:00 -05:00
Add mappings on crop search
This commit is contained in:
@@ -4,12 +4,15 @@ module CropSearch
|
||||
included do
|
||||
####################################
|
||||
# Elastic search configuration
|
||||
searchkick word_start: %i(name description alternate_names scientific_names),
|
||||
searchkick word_start: %i(name description alternate_names scientific_names),
|
||||
case_sensitive: false,
|
||||
merge_mappings: true,
|
||||
mappings: {
|
||||
mappings: {
|
||||
properties: {
|
||||
created_at: { type: :integer }
|
||||
created_at: { type: :integer },
|
||||
plantings_count: { type: :integer },
|
||||
harvests_count: { type: :integer },
|
||||
photos_count: { type: :integer }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,21 +25,21 @@ module CropSearch
|
||||
|
||||
def search_data
|
||||
{
|
||||
name: name,
|
||||
description: description,
|
||||
slug: slug,
|
||||
alternate_names: alternate_names.pluck(:name),
|
||||
name: name,
|
||||
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,
|
||||
plantings_count: plantings_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,
|
||||
scientific_name: default_scientific_name&.name,
|
||||
created_at: created_at.to_i
|
||||
planters_ids: plantings.pluck(:owner_id),
|
||||
has_photos: photos.size.positive?,
|
||||
thumbnail_url: default_photo&.thumbnail_url,
|
||||
scientific_name: default_scientific_name&.name,
|
||||
created_at: created_at.to_i
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,11 +2,13 @@ require 'rails_helper'
|
||||
|
||||
describe 'Crops RSS feed' do
|
||||
it 'The index feed exists' do
|
||||
Crop.reindex
|
||||
visit crops_path(format: 'rss')
|
||||
# expect(page.status_code).to equal 200
|
||||
end
|
||||
|
||||
it 'The index title is what we expect' do
|
||||
Crop.reindex
|
||||
visit crops_path(format: 'rss')
|
||||
expect(page).to have_content "Recently added crops (#{ENV['GROWSTUFF_SITE_NAME']})"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user