Answer the question
In order to leave comments, you need to log in
Post view count?
Hi everyone again.
I got to the point of counting the number of people who viewed the post and I just can’t decide.
Can someone tell me from their experience?
News site, more than 10,000 news.
The collection is needed to sort by the popularity of views per day, week, as well as for the editor for informational content.
I read a lot of everything who says that using a database for this is bad, who says that there are easier solutions.
In general, what I found from Gem-ov
1) https://github.com/biola/punching_bag
In principle, normal, all statistics are available, for any period
2) https://github.com/charlotte-ruby/impressionist
It seems like it’s not bad either, everything that the module above can also do, but at the same time there is some protection against bots and a record of the visitor’s ip in order to prevent the counter from spinning again. It even turns out that this one will be better, since the first one writes only hits and protection from bots and he doesn’t have an Ip record at all, each new entry = a new hit
3) https://github.com/leonid-shevtsov/page_visit_tracker
Also some but did not understand what and how with him, maybe someone knows will say.
I would like to hear from those who have already solved this problem. Of course, I would like to see protection against repeated torsion from one Ip. And of course statistics for the desired period for sorting and information. It seems like option 2 wins in this, but I would like to know your opinion.
Thank you.
Answer the question
In order to leave comments, you need to log in
IMHO, you don't even need gems. Add the views:integer attribute to the post and increment it for each call to the Posts#show action.
Does the probability of cheating views exist in principle? Is there any benefit to anyone from this? Perhaps protection is not even needed at all?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question