-
Notifications
You must be signed in to change notification settings - Fork 115
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
Make search random across all pages #57
Conversation
9eed8c0
to
14ddadf
Compare
Don't worry about build failures – issue with our |
@bnb I was thinking of using |
I think that makes sense 🤔 |
If you filter outside the reduce its a bit less performant because you're looping more than once over the items no? |
Yes, it might be a tiny bit slower, however, it will be negligible due to the size of the dataset(30 max) that we have. Then it comes down to the readability of code, and that is what |
7d2bfcb
to
18988fd
Compare
FWIW it still seems like I'm only getting 1st page with |
@bnb great catch. Found it, just |
@hemal7735 no worries! ❤️ |
Looks like it's working! I got a few from ~3 hours ago, and one from ~11 months ago. 💥 Only comment is that it looks like some lines don't have test coverage. If you could add that, this should be good to go! |
@bnb It is 100% now. Can you check with Travis CI? |
Travis checks look good to me. I'll pull this down and test it out a bit, but when I was testing the other day it looked good. Sanity check and we're good to go 👍 |
Out of 10-15 tries I got mostly issues within the last 48 hours with |
const PER_PAGE = 30 | ||
const PAGE = 1 // page_number is 1-based index | ||
|
||
// API does not allow more than 1000 results -> tested via "feeling-lucky" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So is it possible to change the starting page (PAGE)? It doesn't seem like we're doing that, which would be a vital part of full randomization right? 🤔
Perhaps I'm just not fully understanding what this code is doing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the constants and defaults referred in getSearchParams
function. Any calls made to octokit.search.issues
should use getSearchParams
function inorder to properly generate search-params.
now, although these are defaults, one can override them by passing their search param values.
perhaps, I should use Object.assign
😞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So is it possible to change the starting page (PAGE)?
Yes, we are doing it in the second call made to issues search.
LGTM. Going to merge this + ship it in v0.17.0 👍 |
This PR addresses the concerns shown here: #51 (comment)
How it is done?
I see there is a field called total_count in the response. We can utilize that to figure out the number of pages as default is 30 items per page. So the idea is:
Note:
search.spec.js
.