FEATURE: support search click through tracking for user, category and tags

https://meta.discourse.org/t/search-logs-page/73281/11?u=techapj

This commit adds following features:

- support for tracking click through to user, tag and category
- new filter for search type (header, full page)

This commit also removes "most viewed topic" field from search logs page because we are now tracking multiple click through entities, so topic is not a special entity anymore. This also improves query perf. The query now takes `20.5ms` to runs, as opposed to `655.9ms` previously.
This commit is contained in:
Arpit Jalan
2017-11-28 23:24:27 +05:30
parent f37a1d5976
commit e3925278e2
14 changed files with 126 additions and 62 deletions

View File

@ -179,15 +179,11 @@ RSpec.describe SearchLog, type: :model do
expect(top_trending.searches).to eq(3)
expect(top_trending.unique).to eq(2)
expect(top_trending.click_through).to eq(0)
expect(top_trending.clicked_topic_id).to eq(nil)
popular_topic = Fabricate(:topic)
not_so_popular_topic = Fabricate(:topic)
SearchLog.where(term: 'ruby', ip_address: '127.0.0.1').update_all(clicked_topic_id: popular_topic.id)
SearchLog.where(term: 'ruby', ip_address: '127.0.0.2').update_all(clicked_topic_id: not_so_popular_topic.id)
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.2').update_all(search_result_id: 24)
top_trending = SearchLog.trending.first
expect(top_trending.click_through).to eq(3)
expect(top_trending.clicked_topic_id).to eq(popular_topic.id)
end
end