Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pagination since_id is ignored when max_id is set #89

Closed
pacmessica opened this issue Feb 4, 2019 · 5 comments
Closed

pagination since_id is ignored when max_id is set #89

pacmessica opened this issue Feb 4, 2019 · 5 comments

Comments

@pacmessica
Copy link

For example, if I have the following statusIDs.
100, 99, 98 ... 1

If I make the following call:
/api/v1/timelines/public?since_id=74&max_id=78

I would expect the following results: [77, 76, 75]. This is also what I get when I call the api directly.

However, what I currently see is : [77, 76, 75, 74, 73, 72, ... etc]

I don't understand why go-mastodon deliberately sets since_id to an empty string if a max_id is specified. I would like to be able to paginate through the results until I reach the since_id that I specified, but that's not currently possible because when I specify a max_id, then my since_id value is ignored...

Instead of https://github.com/mattn/go-mastodon/blob/master/mastodon.go#L311

func (p *Pagination) setValues(params url.Values) url.Values {
	if p.MaxID != "" {
		params.Set("max_id", string(p.MaxID))
	} else if p.SinceID != "" {
		params.Set("since_id", string(p.SinceID))
	}
	if p.Limit > 0 {
		params.Set("limit", fmt.Sprint(p.Limit))
	}

	return params
}

why not?:

	if p.MaxID != "" {
		params.Set("max_id", string(p.MaxID))
	}
if p.SinceID != "" {
		params.Set("since_id", string(p.SinceID))
	}
@178inaba
Copy link
Contributor

178inaba commented Feb 5, 2019

This issue is discussed at #86

@pacmessica
Copy link
Author

pacmessica commented Feb 5, 2019

Yeah, I read the above discussion. In that issue you yourself even give this example:

/api/v1/timelines/public?since_id=50&max_id=54 -> 51, 52, 53

But that's not what's happening because if you set max_id, since_id is ignored...

@178inaba
Copy link
Contributor

@pacmessica I am sorry to be late.
I fixed it with #90 !
Please check it!

@pacmessica
Copy link
Author

great, thanks!

@mattn
Copy link
Owner

mattn commented Feb 18, 2019

closable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants