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

Show rank for number of download on gem pages #3658

Open
maximecb opened this issue Mar 28, 2023 · 5 comments · May be fixed by #3812
Open

Show rank for number of download on gem pages #3658

maximecb opened this issue Mar 28, 2023 · 5 comments · May be fixed by #3812

Comments

@maximecb
Copy link

Hi. I'm working on the YJIT project and I was looking at the rubygems.org page for the chunky_png gem:
https://rubygems.org/gems/chunky_png/versions/1.3.5

I saw that this gem has over 110M downloads, which is more than I expected. However, I was wondering how that number compares to other gems. Would it be possible, on the right hand side of the page for an individual gem, to show the "rank" of the gem. As in, based on the total number of downloads, this gem is 83/63,407. This would give more context on how popular an individual gem is.

For more context on why this might be useful: we have a benchmark for the chunky_png gem, and I was wondering how much effort we should spend on making this gem run faster, which is going to be proportional to how popular it is.

I realize that not everyone will care about this metric, but it also seems like it could be a relatively easy change to implement, and there is space on the page to display this extra data point :)

@rubyFeedback
Copy link

rubyFeedback commented Mar 29, 2023

Would it be possible, on the right hand side of the page for an individual gem, to show the "rank" of the gem. As
in, based on the total number of downloads, this gem is 83/63,407.

Would be nice, so I concur there.

We only have to be careful to not make the information too "cluttered". While I think it would be useful and maxime
probably does so too, and many others, we also have to consider users who may prefer less information. But
personally, yup - sounds useful. I guess the placement and size may be important too, e. g. what size (~font size,
box size, roughly) would you recommend for it, and where exactly should that be placed? If you have some spare
time, perhaps a small image file as example? That may help folks visualize the change - but as said, I think it is a
good idea.

@maximecb
Copy link
Author

I would put it on the right hand side close to where the number of downloads is included.

if size is an issue, it could be right under the total number of download, but in a smaller font

10,937,427 downloads
103 of 59,379

@simi
Copy link
Member

simi commented Apr 23, 2023

I was looking into this, but it seems I forgot to post my notes. Let me try to revive those from my psql history and my poor memory.

It should be possible to get overall position using following query.

SELECT position FROM (
  SELECT rubygem_id, row_number() OVER(ORDER BY count DESC) AS position
  FROM gem_downloads WHERE version_id = 0 AND rubygem_id <> 0
) AS q WHERE rubygem_id = 123;")

This results into query taking 150-250ms at staging. To make it faster, we can cache the inner query somehow (using Rails.cache or materialized view in PostgreSQL) since that's global for all pushed gems and refresh periodically in background job each hour or so.


As in, based on the total number of downloads, this gem is 83/63,407.

Btw. @maximecb I got confused by this. I wrote some queries and I have seen different numbers for chunky_png. It took me a while to realize those are just example numbers. 🤦 😅.

@maximecb
Copy link
Author

Btw. @maximecb I got confused by this. I wrote some queries and I have seen different numbers for chunky_png. It took me a while to realize those are just example numbers.

That's pretty funny 😆 How far was I off with my fictional numbers?

... Excited that you're working on this tho :D

@simi
Copy link
Member

simi commented Apr 24, 2023

Btw. @maximecb I got confused by this. I wrote some queries and I have seen different numbers for chunky_png. It took me a while to realize those are just example numbers.

That's pretty funny laughing How far was I off with my fictional numbers?

... Excited that you're working on this tho :D

It seems chunky_png is actually 220/190,170.

@juankuquintana juankuquintana linked a pull request May 21, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants