A
A
Artem2017-03-07 10:27:17
MySQL
Artem, 2017-03-07 10:27:17

How to make a selection from the database by the rating of records no older than 14 days?

Faced with the task of making a news feed with autoload when scrolling for 30 records
, records can be commented, like values ​​are summed up and something like a rating is obtained.
The task is to load 30 records based on the rating (not older than 14 days) in descending order
BUT the bottom line is that in real time users comment and like the rating is rebuilt accordingly if the user received 60 records in the first 2 uploads and while he was viewing them, the rating of one of the records drops and it turns out that with the third load this record may again appear to him
Maybe someone faced with a similar task or have any ideas I will be glad.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Chekanov, 2017-03-07
@LanDer931

When displaying records, in js, store the id of records in an array, when loading records, display only unique ones and put new ids into the array again.

T
Tesla, 2017-03-07
@Tesla

Cache a sorted list of id records for 14 days and use it to select records from the database in 30 pieces.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question