From 07d3991bc82186edf8ab04d10e137dbe34ef4cbe Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 4 Mar 2020 05:36:14 -0800 Subject: [PATCH] Remove Algolia for ClassifiedListings (#6435) [deploy] --- .../concerns/classified_listings_toolkit.rb | 4 ---- app/models/classified_listing.rb | 18 ------------------ db/seeds.rb | 1 - 3 files changed, 23 deletions(-) diff --git a/app/controllers/concerns/classified_listings_toolkit.rb b/app/controllers/concerns/classified_listings_toolkit.rb index 9ba4b44bb..e888ce17c 100644 --- a/app/controllers/concerns/classified_listings_toolkit.rb +++ b/app/controllers/concerns/classified_listings_toolkit.rb @@ -6,13 +6,11 @@ module ClassifiedListingsToolkit def unpublish_listing @classified_listing.published = false @classified_listing.save - @classified_listing.remove_from_index! end def publish_listing @classified_listing.published = true @classified_listing.save - @classified_listing.index! end def update_listing_details @@ -29,7 +27,6 @@ module ClassifiedListingsToolkit def bump_listing_success @classified_listing.bumped_at = Time.current saved = @classified_listing.save - @classified_listing.index! if saved saved end @@ -115,7 +112,6 @@ module ClassifiedListingsToolkit if successful_transaction clear_listings_cache - @classified_listing.index! process_successful_creation else @credits = current_user.credits.unspent diff --git a/app/models/classified_listing.rb b/app/models/classified_listing.rb index f0b258d22..7a7895379 100644 --- a/app/models/classified_listing.rb +++ b/app/models/classified_listing.rb @@ -1,5 +1,4 @@ class ClassifiedListing < ApplicationRecord - include AlgoliaSearch include Searchable SEARCH_SERIALIZER = Search::ClassifiedListingSerializer @@ -43,23 +42,6 @@ class ClassifiedListing < ApplicationRecord validate :validate_tags validate :validate_category - algoliasearch per_environment: true do - attribute :title, :processed_html, :bumped_at, :tag_list, :category, :id, :user_id, :slug, :contact_via_connect, :location, :expires_at - attribute :author do - { username: author.username, - name: author.name, - profile_image_90: ProfileImage.new(author).get(width: 90) } - end - tags do - [tag_list, - "user_#{user_id}", - "organization_#{organization_id}"] - end - attributesForFaceting [:category] - customRanking ["desc(bumped_at)"] - searchableAttributes %w[title processed_html tag_list slug location] - end - scope :published, -> { where(published: true) } def self.cost_by_category(category = "education") diff --git a/db/seeds.rb b/db/seeds.rb index 28ae843d7..af3836a8a 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -288,7 +288,6 @@ Rails.logger.info "12. Creating Classified listings" users = User.order(Arel.sql("RANDOM()")).to_a users.each { |user| Credit.add_to(user, rand(100)) } -ClassifiedListing.clear_index! listings_categories = ClassifiedListing.categories_available.keys listings_categories.each_with_index do |category, index| # rotate users if they are less than the categories