Pagination again
Closed this issue · 10 comments
Hi,
I know that this has been an issue before, but I guess one that wasn't solved completely, or the CS site has changed.
Anyway, are you still looking into figuring out the pagination issue for search?
As it stands now, it looks like you can only get 10 users from search with the same options.
I'm looking into it, but have almost no idea what I am doing =p.
The pagination is triggered by this div though when you scroll on the web site.
https://gist.github.com/jphager2/326655e665e135c6597f
John
Search hasn't had any pagination work done (if you're referring to #1). You're welcome to send a pull request, though!
Maybe you can implement it by parsing the HTML it sends back? Look into the uri
and param
attributes.
Perhaps you could implement the search results by include
ing Enumerator? Have a look at this StackOverflow post for ideas on how to do it.
r
Okay, I've found and tested a way to do it. Would you like to go ahead and try to program it? It can be a good learning experience!
Pay attention to the exclude_ids
parameter, since the code doesn't capture the correct id
s for this specific request...
Hi Roberto,
Thanks for the tips, but I don't really get what you mean (though I am happy to do the work).
What way did you find/test?
I haven't noticed an exclude_ids parameter...
Are you looking at the api /msearch or the /search on the CS site?
What I've tried is just getting /search/get_more_results?#{params}, but that just gives you +10.
What I don't understand is that it doesn't seem like there is any info in the parameters that suggests which users to get back (like a starting id or number of user in the query). And I also notice that when you scroll to paginate on the search page, the params in the pagination div do not change.
So anyway, I'm interested in hearing what you found out.
John
Oh, I see. I'm using the API backend, at /msearch
(Thought that was pretty clear by reading the code and the project's description). I found a way to implement what you need and tested it so I can get more than one single page of 10 results for search.
See this gist where the http requests and body of a search result are returned. Look at the differences, then you might get a better picture on what needs to be done.
Hope this helps.
Ok cool. Totally makes sense that it would be the api's /msearch. I just wanted to clarify because I was originally looking at /search.
Thanks for the gist.
Ok. So this is what I have so far.
I think that I don't really understand the way the request works.
In the url params it gives the ids to be excluded one at a time, but when I make the request with HTTParty, I should be able to do :excludes_ids => [1231231,12343432, ...], right?
forgot the gist: https://gist.github.com/jphager2/a220ddd2d77f4e6d101d
alright, I see you use this :string_id
very cool solution with def next_page = proc.
Is that just so you can keep all the real logic on the csapi.rb file?
Actually, this was kind of my first 'real' ruby project, so I didn't know better :/
I've begun to reorganize stuff and just did a quick rewrite of this -almost- abandoned project, you can see how I ended up implementing stuff in the dev branch
I'll go ahead and close this issue. Thanks for getting me to maintain this project!
haha no problem