[deploy] Remove Algolia from Podcast Episodes (#7489)

This commit is contained in:
Molly Struve 2020-04-24 17:36:13 -05:00 committed by GitHub
parent 31c0b388e5
commit 94f3a4b6fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 72 deletions

View file

@ -34,4 +34,8 @@ class PodcastEpisodeDecorator < ApplicationDecorator
podcastImageUrl: image_url
}
end
def published_at_int
published_at.to_i
end
end

View file

@ -3,9 +3,7 @@ class PodcastEpisode < ApplicationRecord
duration_in_seconds
]
include AlgoliaSearch
include Searchable
SEARCH_SERIALIZER = Search::PodcastEpisodeSerializer
SEARCH_CLASS = Search::FeedContent
@ -14,6 +12,7 @@ class PodcastEpisode < ApplicationRecord
delegate :slug, to: :podcast, prefix: true
delegate :image_url, to: :podcast, prefix: true
delegate :title, to: :podcast, prefix: true
delegate :published, to: :podcast
belongs_to :podcast
has_many :comments, as: :commentable, inverse_of: :commentable
@ -44,45 +43,10 @@ class PodcastEpisode < ApplicationRecord
joins(:podcast).where(podcasts: { creator_id: user.id })
}
algoliasearch per_environment: true do
attribute :id
add_index "searchables",
id: :index_id,
per_environment: true do
attribute :title, :body, :quote, :summary, :subtitle, :website_url,
:published_at, :comments_count, :path, :class_name,
:user_name, :user_username, :published, :comments_blob,
:body_text, :tag_list, :tag_keywords_for_search,
:positive_reactions_count, :search_score
attribute :user do
{ name: podcast.name,
username: user_username,
profile_image_90: ProfileImage.new(user).get(width: 90) }
end
searchableAttributes ["unordered(title)",
"body_text",
"tag_list",
"tag_keywords_for_search",
"user_name",
"user_username",
"comments_blob"]
attributesForFaceting [:class_name]
customRanking ["desc(search_score)", "desc(hotness_score)"]
end
end
def search_id
"podcast_episode_#{id}"
end
def user_username
podcast_slug
end
def user_name
podcast_title
end
def comments_blob
comments.pluck(:body_markdown).join(" ")
end
@ -93,22 +57,10 @@ class PodcastEpisode < ApplicationRecord
"/#{podcast.slug}/#{slug}"
end
def published_at_int
published_at.to_i
end
def published
true
end
def description
ActionView::Base.full_sanitizer.sanitize(body)
end
def main_image
nil
end
def profile_image_url
image_url || "http://41orchard.com/wp-content/uploads/2011/12/Robot-Chalkboard-Decal.gif"
end
@ -117,10 +69,6 @@ class PodcastEpisode < ApplicationRecord
ActionView::Base.full_sanitizer.sanitize(processed_html)
end
def user
podcast
end
def zero_method
0
end
@ -144,16 +92,8 @@ class PodcastEpisode < ApplicationRecord
alias second_user_id nil_method
alias third_user_id nil_method
def liquid_tags_used
[]
end
private
def index_id
"podcast_episodes-#{id}"
end
def bust_cache
PodcastEpisodes::BustCacheWorker.perform_async(id, path, podcast_slug)
end

View file

@ -5,16 +5,13 @@ module Search
attribute :id, &:search_id
attributes :body_text, :class_name, :comments_count, :hotness_score, :path,
:positive_reactions_count, :published_at, :quote,
:positive_reactions_count, :published, :published_at, :quote,
:reactions_count, :search_score, :subtitle, :summary, :title,
:website_url
attribute :main_image do |pde|
ProfileImage.new(pde.podcast).get(width: 90)
end
attribute :published do |pde|
pde.podcast.published
end
attribute :slug, &:podcast_slug
attribute :tags do |pde|

View file

@ -60,13 +60,6 @@ RSpec.describe PodcastEpisode, type: :model do
end
end
describe "#index_id" do
it "is equal to articles-ID" do
# NOTE: we shouldn't test private things but cheating a bit for Algolia here
expect(podcast_episode.send(:index_id)).to eq("podcast_episodes-#{podcast_episode.id}")
end
end
describe ".available" do
let_it_be(:podcast) { create(:podcast) }