Skip to content

Fix "I'm feeling lucky" query and add metrics #789

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

Closed
Kixiron opened this issue May 30, 2020 · 4 comments
Closed

Fix "I'm feeling lucky" query and add metrics #789

Kixiron opened this issue May 30, 2020 · 4 comments
Labels
A-crate-search Area: A problem or feature request for searching crates P-low Low priority issues

Comments

@Kixiron
Copy link
Member

Kixiron commented May 30, 2020

This snippet states that the query was made for a vastly different docs.rs, one that had 280 crates with docs. We now have over 200k crates, so this should probably get fixed. Additionally, metrics for it would be interesting, because why not?

@Kixiron Kixiron added the A-crate-search Area: A problem or feature request for searching crates label May 30, 2020
@jyn514
Copy link
Member

jyn514 commented May 30, 2020

That part of the code is only run if the query is empty, i.e. someone hit "I'm feeling lucky" without putting anything in the search box. In that case I think selecting a random crate is fine.

@Kixiron
Copy link
Member Author

Kixiron commented May 30, 2020

It's definitely far from perfect, as it can panic if the offset is off. For example, my test db only has ~50 crates right now, so since the offset is calculated with FLOOR(RANDOM() * 280) that always panics except when RANDOM() is 0

@Kixiron
Copy link
Member Author

Kixiron commented May 30, 2020

The math of my last comment may be a wee off, but point stands, it may even be possible (if horrifically improbable) that it panics in prod

@syphar
Copy link
Member

syphar commented Mar 21, 2021

This was fixed in #1251 and #1260, so it could be closed.

@syphar syphar closed this as completed Mar 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-crate-search Area: A problem or feature request for searching crates P-low Low priority issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants