Infinit Scrolling and Limitations On Social Site

I’ve read: Why Infinite Scrolling sucks

I have implemented a JavaScript that when I scroll sends an Ajax-request to a file (a PHP one) on the server, and the PHP returns an amount of items (as HTML list <li></li>), and this happens through a LIMIT limit, offset in the MySQL query.

The main issue is that I am Aggregating and Grouping data based on DATE, user ID, and the hh:mm:ss difference (the hh:mm:ss sort and grouping is done after the other two are in place).

The problem is having to add a LIMIT 10, means that if someone posted 10 items within an hour, and the next minutes later another user posted something which is now #1 in the retrieved list, and the other 10 items posted under that same hour by the previous user are appearing below this one.

So LIMIT 10 grabs the first 10 items, but the problem is that even the 11th item belongs to the user that made the other 9 ones within that HOUR time stamp.

How is something like this solved?

Hi,

I’m not sure that I understood the problem right, but here is algorithm that I would use:

  • When user opens the list, retrieve first 10 entries;
  • Remember timestamp of the last one of those 10 entries (on the client side);
  • When user scrolls down send new request with timestamp;
  • Select next 10 entries filtered by the timestamp of the last retrieved entry (WHERE date > last_timestamp LIMIT 10)

That will guarantee that user receives correct old entries even if the list already has new entries at the top

1 Like

Hi @megazoid,

Thanks a lot for your reply! Let me try to explain,

So let’s say, the time right now is: 10:00 and between 10:00 and 11:00 (that is any minute + second, example time only, can actually be anytime). A user decides to post 3 posts and another user decides to post 5 posts. Now the idea is to** group multiple items by a particular user within a certain time-frame**, so if the time difference isn’t huge but it’s kept between 10:00 and 11:00 (example time only, can actually be anytime) then the items shall be grouped.

So,

User A posted 3 posts.

User B posted 5 posts. 

And these are order in DESC order. Latest first oldest last.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.