Skip to content

A platform for community discussion. Free, open, simple.

DEV: Remove the unique_searches column from select query

Vinoth Kannan9c6f77f9dab0
diff --git a/app/models/search_log.rb b/app/models/search_log.rb
index 738760fdb67..d046daee06c 100644
--- a/app/models/search_log.rb
+++ b/app/models/search_log.rb
@@ -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
diff --git a/spec/models/search_log_spec.rb b/spec/models/search_log_spec.rb
index d78a8800b81..c98dda028e6 100644
--- a/spec/models/search_log_spec.rb
+++ b/spec/models/search_log_spec.rb
@@ -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)