FEATURE: index YouTube titles in search

Previously we omitted the titles for videos that YouTube provided
This commit is contained in:
Sam 2018-04-26 15:46:52 +10:00
parent 55179efdb9
commit 6676bbd38b
2 changed files with 13 additions and 0 deletions

View File

@ -196,6 +196,11 @@ class SearchIndexer
scrubbed << attributes["title"]
scrubbed << " "
end
if attributes["data-youtube-title"]
scrubbed << " "
scrubbed << attributes["data-youtube-title"]
scrubbed << " "
end
end
def characters(string)

View File

@ -13,6 +13,14 @@ describe SearchIndexer do
expect(raw_data.split(' ').length).to eq(2)
end
it 'extract youtube title' do
html = "<div class=\"lazyYT\" data-youtube-id=\"lmFgeFh2nlw\" data-youtube-title=\"Metallica Mixer Explains Missing Bass on 'And Justice for All' [Exclusive]\" data-width=\"480\" data-height=\"270\" data-parameters=\"feature=oembed&amp;wmode=opaque\"></div>"
scrubbed = SearchIndexer::HtmlScrubber.scrub(html)
expect(scrubbed).to eq(" Metallica Mixer Explains Missing Bass on 'And Justice for All' [Exclusive] ")
end
it 'correctly indexes a post according to version' do
# Preparing so that they can be indexed to right version
SearchIndexer.update_posts_index(post_id, "dummy", "", nil, nil)