Take the 2-minute tour ×
Stack Apps is a question and answer site for apps, scripts, and development with the Stack Exchange API. It's 100% free, no registration required.

I know I can retrieve a page of users ordered by reputation using these apis:

http://api.stackoverflow.com/1.1/users/?sort=reputation&order=desc&page=1

http://api.stackoverflow.com/1.1/users/?sort=reputation&order=desc&page=2

Now, let's assume I get the first page of 30 users and the last user of that page (Peter) has reputation of 136519. If I immediately ask for the second page, the first user of this page (John) has reputation 136515, 4 less than the last user of page one.

Let's now assume I wait for a bit longer to ask for the second page. In this case, it could happen that John increases his reputation by 10 and Peter gets pushed down to the second page. When I ask for the second page, I find Peter again as the first user of page 2.

This can be a problem especially if I want to display the list in a scrolling view, like the one used in the StackAnywhere mobile app: in the case described above I would see Peter twice (and skip John) if I called the api while scrolling down the list.

How can this problem be avoided? Has StackAnywhere implemented any clever trick to avoid it, or simply lets it happen in the unlikely event it comes up?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

StackAnywhere has so far not attempted solve this problem. A similar issue exists for question lists. In fact it's more likely to be an issue here because when the list is sorted by date, new questions can push others down the list resulting in duplicate entries.

It's an open issue in the StackAnywhere bug tracker at the moment.

share|improve this answer
    
Thanks Dan. I was thinking that a partial workaround could be at least to avoid repeating the same item in the list. This can be easily done on Android by checking if the item id is already in the list every time you fetch a new page. This way, you'll miss items that have been inserted in previous pages, but you won't see duplicates. However, if an item is deleted from a previous page, the first item of the new page will scroll up into the previous page and you'll miss it. I think there is nothing to do in this case. –  Lorenzo Polidori Feb 23 '12 at 10:09
add comment

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .