Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

/posts?since_id=foo retrieves the newest NLIMIT after foo rather than the oldest NLIMIT after foo #54

Closed
ragfield opened this Issue · 8 comments

3 participants

@ragfield

From tent.dev:

When I fetch new posts I specify since_id and since_id_entity. When there are more than 50 new posts I assumed this would return the 50 immediately following the post I specified. I just discovered it's actually returning the 50 newest posts, leaving a gap between my previous newest post and the oldest post returned. Apparently I'm going to have to resolve this somehow. But the behavior seems weird to me. With the current behavior since_id isn't really useful for what I'm doing, aside from possibly limiting the number of posts returned if there are fewer than 50 new posts. Is this the intended behavior?

and:

Sure. I've wrapped my head around the behavior and I'm adjusting my code to account for it. I haven't yet figured out how to handle the following situation:

  • I have a range of posts already loaded
  • I request newer posts
  • I receive the first page of newer posts
  • I request the next page of newer posts and encounter a network error or my app crashes

Now I'm left with a gap between the newest post in my original range and the oldest post I was able to download before encountering problems. I guess I'll just have to do a lot of extra bookkeeping to keep track of all the potential missing ranges.

@titanous
Owner

To make this more clear, I've made a diagram of the way it should work:

tent_pagination

@jvatic jvatic referenced this issue from a commit
@jvatic jvatic Fix since_id behavior
refs #54
f8cc8d8
@jvatic
Owner

f8cc8d8 fixes this

@jvatic jvatic closed this
@jvatic
Owner

Actually, since_time behavior is still wrong...

@jvatic jvatic reopened this
@jvatic jvatic referenced this issue from a commit
@jvatic jvatic Fix since_time behavior
refs #54
bbb2230
@jvatic jvatic closed this
@ragfield

Wait, did this change the order the posts are returned in? Now when I specify since_id the posts are returned with the oldest one first and the newest one last?

@ragfield

Here's what I'm seeing if it helps.

Request most recent posts, comes back sorted newest to oldest:

In[292]:= postInfo[post_TentPost]:={TentPostID[post],TentPostEntityRaw[post]};
In[294]:= Column[postInfo/@(posts=TentPosts[bivyme,{"limit"->"10"}])]
Out[294]= {vzbeko,https://fmgagnon.tent.is}
{3q1dl1,https://jonathan.tent.is}
{1eb81c,https://bivyme.tent.is}
{hmy0xt,https://sexyhermit.tent.is}
{5dicfe,https://poweruser.tent.is}
{cec9x0,https://bivyme.tent.is}
{ixe7r6,https://poweruser.tent.is}
{8tuxvf,https://marcfiszman.tent.is}
{5lgsb1,https://poweruser.tent.is}
{dgnt2h,https://poweruser.tent.is}

Request posts before the most recent post, comes back sorted newest to oldest:

In[297]:= Column[postInfo/@(TentPosts[bivyme,{"limit"->"9","before_id"->TentPostID@First@posts,"before_id_entity"->TentPostEntityRaw@First@posts}])]
Out[297]= {3q1dl1,https://jonathan.tent.is}
{1eb81c,https://bivyme.tent.is}
{hmy0xt,https://sexyhermit.tent.is}
{5dicfe,https://poweruser.tent.is}
{cec9x0,https://bivyme.tent.is}
{ixe7r6,https://poweruser.tent.is}
{8tuxvf,https://marcfiszman.tent.is}
{5lgsb1,https://poweruser.tent.is}
{dgnt2h,https://poweruser.tent.is}

Request posts since 10th most recent post, comes back sorted oldest to newest:

In[299]:= Column[postInfo/@(TentPosts[bivyme,{"limit"->"9","since_id"->TentPostID@Last@posts,"since_id_entity"->TentPostEntityRaw@Last@posts}])]
Out[299]= {5lgsb1,https://poweruser.tent.is}
{8tuxvf,https://marcfiszman.tent.is}
{ixe7r6,https://poweruser.tent.is}
{cec9x0,https://bivyme.tent.is}
{5dicfe,https://poweruser.tent.is}
{hmy0xt,https://sexyhermit.tent.is}
{1eb81c,https://bivyme.tent.is}
{3q1dl1,https://jonathan.tent.is}
{vzbeko,https://fmgagnon.tent.is}

@titanous
Owner

Yeah, that's a bug, @jvatic is on it.

@jvatic jvatic referenced this issue from a commit
@jvatic jvatic Fix since_id/since_time sorting
refs #54
772369e
@jvatic
Owner

This should be working as expected now (see 772369e)

@ragfield

Yes, it appears to be working now. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.