简体   繁体   English

Ruby on Rails搜索网站的活动记录系统

[英]Activity logging system for Ruby on Rails search site

I have a horse search site built in Ruby on Rails - FindHorsesForSale.net, and want to build an activity logging system that will tell me: - how many times a listing appeared in search results - how many times a listing appeared on a details page - the click through rate of each position in search results 我有一个在Ruby on Rails中构建的骑马搜索网站-FindHorsesForSale.net,并且想要构建一个活动日志记录系统,该系统将告诉我:-列表出现在搜索结果中的次数-列表出现在详细信息页面上的次数-搜索结果中每个位置的点击率

The app is hosted on Heroku. 该应用程序托管在Heroku上。 Any recommendations on how to build something scalable to answer the questions above? 关于如何构建可扩展的内容以回答上述问题的任何建议?

I think the best way would be another Model for counting hits including a hit_type field to differ between hits in search and hits of the profile. 我认为最好的方法是使用另一个Model来计算点击数,其中包括hit_type字段,以使搜索的点击数与个人资料的点击数之间有所不同。 The model could look like this: 该模型可能如下所示:

Hit hit_type:string user_agent:string ip:string horse_id:integer`

Then you associate the Hit Model with the Horse model via has_many and in the search action you create a new object of hit for each found horse and also a new hit Object for each view of the profile. 然后,通过has_manyHit模型与Horse模型关联,并在搜索操作中为每个找到的马创建一个hit的新对象,并为该配置文件的每个视图创建一个新的hit对象。 The only difference will be the hit_type which could be "search" and "profile" for example. 唯一的区别是hit_type,例如可以是“ search”和“ profile”。 Then you could write scopes for both in Hit Model: 然后,您可以在Hit Model中为两者编写范围:

scope :searched, where("hit_rype = ?", "search")
scope :viewed, where("hit_type = ?", "view")

THen you could easy check the horses views: 然后您可以轻松查看马匹的景色:

horse.hits.searched.count # returns count of views
horse.hits.viewed # returns count of profile views

Hope this helps you! 希望这对您有所帮助!

// I had a look at your sites. //我浏览了您的网站。 If your doing buisness with your websites you should know about SEO so your found! 如果您在网站上做生意,那么您应该对SEO有所了解,所以您会发现! All your domainnames use camelCase but google doenst recognise camelCase in domainnames, words,... Just a hint 您所有的域名都使用camelCase,但是google doenst会在域名,单词,...等中识别camelCase。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM