diff --git a/app/models/concerns/crop_search.rb b/app/models/concerns/crop_search.rb index 65e1499a2..59facda5e 100644 --- a/app/models/concerns/crop_search.rb +++ b/app/models/concerns/crop_search.rb @@ -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 diff --git a/spec/features/rss/crops_spec.rb b/spec/features/rss/crops_spec.rb index 704dd60ba..e42c73150 100644 --- a/spec/features/rss/crops_spec.rb +++ b/spec/features/rss/crops_spec.rb @@ -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