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

bug(API): top parameter #3163

Closed
timdeschryver opened this issue Jun 14, 2019 · 3 comments
Closed

bug(API): top parameter #3163

timdeschryver opened this issue Jun 14, 2019 · 3 comments

Comments

@timdeschryver
Copy link

Describe the bug

The top parameter in the query string does not top the results.

To Reproduce

Without tag:
https://dev.to/api/articles?top=2

With tag:
https://dev.to/api/articles?tag=react&top=2

Something weird:

This does top the results
https://dev.to/api/articles?tag=Angular&top=2

While this does not
https://dev.to/api/articles?tag=Angular&top=1
https://dev.to/api/articles?tag=Angular&top=3

Expected behavior

I would expect that the results would be topped, for example top=2 should return 2 results.

Additional context

There are tests written on the API, but these aren't validating the length of the returned results
https://github.com/thepracticaldev/dev.to/blob/master/spec/requests/api/v0/articles_spec.rb#L56

@timdeschryver
Copy link
Author

I think I was wrong, from what I can see the API doesn't support a top parameter.

It's still a bit strange that the results aren't the same (based on the top parameter), that's why I'll keep this issue open. Feel free to close if you'd like 🙂

https://github.com/thepracticaldev/dev.to/blob/master/app/controllers/api/v0/articles_controller.rb#L48

@rhymes
Copy link
Contributor

rhymes commented Jun 17, 2019

Hi @timdeschryver I think you were right, the API supports a top parameter, it's just that it doesn't work exactly like you initially presumed.

top indicates the number of days, not the number of articles, see

https://github.com/thepracticaldev/dev.to/blob/5f5ae5567e5bed1a65e8cffab7f4d8d7cbe7d86a/app/services/article_api_index_service.rb#L69-L72

(it's called from https://github.com/thepracticaldev/dev.to/blob/master/app/controllers/api/v0/articles_controller.rb#L19)

There's currently no way to specify the number of items returned by pagination in that endpoint

@timdeschryver
Copy link
Author

Oh, my bad 😅!
Thanks pointing me to the correct location @rhymes.

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

2 participants