DEV: Remove the unique_searches column from select query

This commit is contained in:
Vinoth Kannan 2018-12-19 02:45:48 +05:30
parent 6080e3a2c0
commit 9c6f77f9da
2 changed files with 2 additions and 4 deletions

View File

@ -125,8 +125,7 @@ class SearchLog < ActiveRecord::Base
SUM(CASE
WHEN search_result_id IS NOT NULL THEN 1
ELSE 0
END) AS click_through,
COUNT(DISTINCT ip_address) AS unique_searches
END) AS click_through
SQL
result = SearchLog.select(select_sql)
@ -141,7 +140,7 @@ class SearchLog < ActiveRecord::Base
end
result.group('lower(term)')
.order('searches DESC, click_through DESC, unique_searches DESC, term ASC')
.order('searches DESC, click_through DESC, term ASC')
.limit(limit)
end

View File

@ -204,7 +204,6 @@ RSpec.describe SearchLog, type: :model do
top_trending = SearchLog.trending.first
expect(top_trending.term).to eq("ruby")
expect(top_trending.searches).to eq(3)
expect(top_trending.unique_searches).to eq(2)
expect(top_trending.click_through).to eq(0)
SearchLog.where(term: 'ruby', ip_address: '127.0.0.1').update_all(search_result_id: 12)