S
S
Sergey Beloventsev2016-05-14 21:43:43
MySQL
Sergey Beloventsev, 2016-05-14 21:43:43

How to organize a rating on a site by clicking on a button?

I'm trying to solve the problem with the construction of the bike again. I need to organize the top entries by clicking on the favorites button. But not just the top by the number of clicks was displayed, but also so that a counter of click changes per day was implemented, that is, relatively speaking today, five people more signed up, +5 is displayed if they unsubscribed -5. If such solutions are described, please post a link.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Donkovtsev, 2016-05-15
@Demetriy

There is nothing non-standard here, I would do this:
1) Table for favorites: user, material, time, etc.
Comparing the number of likes for yesterday and today is not a problem in this case, but if your number of likes is in the tens of thousands per post, then you can also add a table with data aggregated per day for each post and update it n times a day.
2) The field next to the record, in which the number of likes is written, to make it easier to compare records with each other, display aggregated values, etc., without referring to the table from paragraph 1.
To update this field, you can hang it on a trigger (on the DB side) or register it in the model methods, I would choose the second one, because, if after you someone will work with the code or a large team, then everyone about the trigger you need to know, etc., and when it is in the code, you can immediately see it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question