DEV: Remove the unique_searches column from select query
This commit is contained in:
parent
6080e3a2c0
commit
9c6f77f9da
|
@ -125,8 +125,7 @@ class SearchLog < ActiveRecord::Base
|
||||||
SUM(CASE
|
SUM(CASE
|
||||||
WHEN search_result_id IS NOT NULL THEN 1
|
WHEN search_result_id IS NOT NULL THEN 1
|
||||||
ELSE 0
|
ELSE 0
|
||||||
END) AS click_through,
|
END) AS click_through
|
||||||
COUNT(DISTINCT ip_address) AS unique_searches
|
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
result = SearchLog.select(select_sql)
|
result = SearchLog.select(select_sql)
|
||||||
|
@ -141,7 +140,7 @@ class SearchLog < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
result.group('lower(term)')
|
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)
|
.limit(limit)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -204,7 +204,6 @@ RSpec.describe SearchLog, type: :model do
|
||||||
top_trending = SearchLog.trending.first
|
top_trending = SearchLog.trending.first
|
||||||
expect(top_trending.term).to eq("ruby")
|
expect(top_trending.term).to eq("ruby")
|
||||||
expect(top_trending.searches).to eq(3)
|
expect(top_trending.searches).to eq(3)
|
||||||
expect(top_trending.unique_searches).to eq(2)
|
|
||||||
expect(top_trending.click_through).to eq(0)
|
expect(top_trending.click_through).to eq(0)
|
||||||
|
|
||||||
SearchLog.where(term: 'ruby', ip_address: '127.0.0.1').update_all(search_result_id: 12)
|
SearchLog.where(term: 'ruby', ip_address: '127.0.0.1').update_all(search_result_id: 12)
|
||||||
|
|
Loading…
Reference in New Issue