X
X
Xrist1An2015-10-17 17:47:04
PHP
Xrist1An, 2015-10-17 17:47:04

Displaying popular posts on the site for a certain period, how?

There is a database with articles and you need to somehow sort by popularity for a week, month or any other period.
I can't quite figure out the best way to implement this.
In the database, each entry has a time when it was loaded and a view counter, but as I understand it, this information will be useless for such sorting. It can only be used for ALL time sorting.
I think this problem has already been solved a million times, do not tell me how?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2015-10-17
@Xrist1An

Well, it means that we must also aggregate statistics on views per day. The easiest option is to start a view log, but then the database will quickly become clogged with all sorts of nonsense. Further, we can optimize this business and simply reset the view counter to zero once a day and record how many views there were for such and such a date. So we will have a reliable infa for the sample.

S
Sergey Goryachev, 2015-10-17
@webirus

Why, quite a useful function. First you need to filter out all articles older than 7 days, then sort all articles by the number of views. There is nothing complicated.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question