Skip to content

Expose rubygem reverse depencencies#945

Merged
homu merged 5 commits into
rubygems:masterfrom
spk:expose-reverse-dependencies
Dec 28, 2016
Merged

Expose rubygem reverse depencencies#945
homu merged 5 commits into
rubygems:masterfrom
spk:expose-reverse-dependencies

Conversation

@spk
Copy link
Copy Markdown
Contributor

@spk spk commented Apr 29, 2015

rails_reverse_dependencies_search_jquery

@dwradcliffe
Copy link
Copy Markdown
Member

Can you post a screenshot?

@spk
Copy link
Copy Markdown
Contributor Author

spk commented Apr 29, 2015

@dwradcliffe yes it's on the description

@francois2metz
Copy link
Copy Markdown

<3

@sferik
Copy link
Copy Markdown
Member

sferik commented Apr 29, 2015

As the maintainer of many gems, this information is incredibly useful to me—knowing which gems depend on mine, so I can see how they’re being used—but I remember when we benchmarked this query it was rather slow. Since this information is not broadly useful (to 99% of gem users vs. 1% of gem maintainers), it may make more sense to put on a separate page, so the query doesn’t need to run every time someone looks at a gem page.

Also, have you tested that this will work on specific gem version pages? For example if gem a depends on gem b ~> 1.0, gem a should appear as a reverse dependency for gem b version 1.0.0 and 1.9.9, but not 0.9.9 or 2.0.0. There may already be unit tests for this case but I’d feel better if we had functional/controller tests covering it.

@spk
Copy link
Copy Markdown
Contributor Author

spk commented Apr 30, 2015

I see what you mean @sferik, and I did not try with the production database.
I will work on a separate page version, with versions selection.
Thank you for the feedback.

@sferik
Copy link
Copy Markdown
Member

sferik commented Apr 30, 2015

@spk 👍 Thank you for working on this feature. I’m really looking forward to the day when it’s merged and deployed.

@spk
Copy link
Copy Markdown
Contributor Author

spk commented May 1, 2015

With latest production database, with rails the query is about 151.6ms and give 8073 reverse dependencies to rails gem!
So yes another page with version and pagination is required!

@simi
Copy link
Copy Markdown
Contributor

simi commented May 1, 2015

Maybe it will be handy to sort gems by download count.

@spk
Copy link
Copy Markdown
Contributor Author

spk commented May 2, 2015

I think I have a usable feature, with pagination, search filter and ordered by download (thanks @simi).
For versions I'm using the same method as in the API, but it don't filter with major/minor version @sferik.

@spk spk force-pushed the expose-reverse-dependencies branch from 9fcb184 to 5515976 Compare May 3, 2015 08:57
@parndt
Copy link
Copy Markdown
Contributor

parndt commented May 10, 2015

As a gem maintainer, this is a really helpful feature.. thank you!

@spk
Copy link
Copy Markdown
Contributor Author

spk commented May 11, 2015

Thanks! Is it possible to have a review by the team and get it merge ?

@sferik
Copy link
Copy Markdown
Member

sferik commented May 11, 2015

👍 Looks good to me. I’d like to see a 👍 from at least one other maintainer before merging.

/cc @qrush @evanphx @skottler @dwradcliffe

@qrush
Copy link
Copy Markdown
Member

qrush commented May 11, 2015

A few comments-

  1. I feel this would been cleaner implemented as ReverseDependenciesController - anything that isn't a RESTful action tends to be a smell, eventually. That can wait for a refactoring PR if anyone is up for it.
  2. The HTML view is pretty barebones. Can we show the same partial as on searches#show, and possibly get that cached?
  3. We'll have to watch performance a little more carefully when this is deployed - at least paginating it helps.

@simi
Copy link
Copy Markdown
Contributor

simi commented May 11, 2015

I'm going to review this today.

@spk spk force-pushed the expose-reverse-dependencies branch 2 times, most recently from 95dd967 to 70c25b3 Compare May 17, 2015 12:53
@spk spk force-pushed the expose-reverse-dependencies branch from 70c25b3 to 76fa2e9 Compare May 23, 2015 10:43
@spk spk force-pushed the expose-reverse-dependencies branch from 76fa2e9 to 324918d Compare June 16, 2015 21:32
@spk spk force-pushed the expose-reverse-dependencies branch from 324918d to 2acaddb Compare July 2, 2015 18:16
@spk
Copy link
Copy Markdown
Contributor Author

spk commented Jul 2, 2015

Status since last review:

  • Performance issue fixed by 3e13be0
  • Nicer templates using existing and share aside sidebar

@oz
Copy link
Copy Markdown

oz commented Jul 5, 2015

This would be a nice feature. I hope you guys find time to merge this. 👍

@qrush
Copy link
Copy Markdown
Member

qrush commented Jul 7, 2015

Is there any way we can get this on a "feature flag" type system? So if we deploy it and need to turn it off fast w/o rollback that would be feasible. Any thoughts @dwradcliffe @arthurnn ?

@dwradcliffe
Copy link
Copy Markdown
Member

@qrush good idea 👍

@arthurnn
Copy link
Copy Markdown
Member

arthurnn commented Jul 8, 2015

"feature flag" , should be easy to make it work. 👍 from me.. the only thing I hate about those is that people tend to leave features behind, and the code start getting 2+ code paths.. As long as we remember that. I am fine

@spk spk force-pushed the expose-reverse-dependencies branch 3 times, most recently from 14cea47 to 4a54ddc Compare July 15, 2015 19:52
@bf4
Copy link
Copy Markdown
Contributor

bf4 commented Jul 17, 2015

Great job! These pages would definitely need to be throttled so someone couldn't use it to DDoS the site ;) That is, they should have a default/fallback state of 'unavailable' at this time when the data is not available, for whatever reason.

Also, any consideration to do this in JavaScript via the API, perhaps like gemloupe did? (bookmarklet below)

javascript:(function(){var script=document.createElement('SCRIPT');script.src='https://www.gemlou.pe/assets/remote_loupe_consumer.js';document.body.appendChild(script);})()

I'd be happy to do the JS as an Ember Component

@spk spk force-pushed the expose-reverse-dependencies branch from 53b651c to fc5785e Compare November 20, 2016 17:51
@sonalkr132
Copy link
Copy Markdown
Member

@spk I have bad news 😓

It has n+1 for gem_download. Also, Versions.reverse_dependencies(name) is too effin slow 😭

  def self.reverse_dependencies(name)
    joins(dependencies: :rubygem)
      .indexed
      .where(rubygems: { name: name })
  end

I think first finding the gem and then using id instead of name would be way faster. Do you think you can benchmark two options and open an issue?

@spk
Copy link
Copy Markdown
Contributor Author

spk commented Nov 21, 2016

@sonalkr132 not that bad !
For the record those methods are already used on the API
I can work on that maybe later this week

@sonalkr132
Copy link
Copy Markdown
Member

I can work on that maybe later this week

Sure 👍

@kbrock
Copy link
Copy Markdown
Contributor

kbrock commented Nov 22, 2016

not sure if this needs an index. And does this want to be case insensitive? (use lower)

@spk spk force-pushed the expose-reverse-dependencies branch from 3f7b4eb to 4a48e62 Compare December 5, 2016 19:22
before_action :set_page, only: [:index]

def index
@latest_version = @rubygem.versions.most_recent
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't @latest_version already set with before_action :latest_version?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes its a mistake; fixed in 61a5a90

<header class="gems__header push">
<%= form_tag rubygem_reverse_dependencies_path(@rubygem),
:id => "rdeps-search", :class => "header__search-wrap", :method => :get do %>
<%= search_field_tag :rdeps_query, params[:rdeps_query], :placeholder => "Search Reverse Deps Gems&hellip;".html_safe, :class => "header__search" %>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use I18n for placeholder.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 5ef01ec

:id => "rdeps-search", :class => "header__search-wrap", :method => :get do %>
<%= search_field_tag :rdeps_query, params[:rdeps_query], :placeholder => "Search Reverse Deps Gems&hellip;".html_safe, :class => "header__search" %>
<%= label_tag :rdeps_query do %>
<span class="t-hidden">Search gems</span>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use I18n.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 5ef01ec

@spk spk force-pushed the expose-reverse-dependencies branch from 4a48e62 to 5ef01ec Compare December 18, 2016 17:42
before_action :set_page, only: [:index]

def index
@reverse_dependencies = @rubygem.reverse_dependencies.by_downloads
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use @rubygem.reverse_dependencies.by_downloads.includes(:latest_version, :gem_download) instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see 012c1e2

@@ -0,0 +1,12 @@
<header class="gems__header push">
<%= form_tag rubygem_reverse_dependencies_path(@rubygem),
:id => "rdeps-search", :class => "header__search-wrap", :method => :get do %>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use ruby 1.9 hash syntax.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see fa0f34b

@spk spk force-pushed the expose-reverse-dependencies branch from 5ef01ec to 2a25ff4 Compare December 21, 2016 17:53
@indirect
Copy link
Copy Markdown

@homu r+

@homu
Copy link
Copy Markdown
Contributor

homu commented Dec 28, 2016

📌 Commit 012c1e2 has been approved by indirect

homu added a commit that referenced this pull request Dec 28, 2016
Expose rubygem reverse depencencies

![rails_reverse_dependencies_search_jquery](https://cloud.githubusercontent.com/assets/98590/7667144/605ee3a4-fbfe-11e4-94ae-6d71442aa5a5.png)

- [x] rebase after #1498 merged
- [x] Fix rubocop on rubygem_helper class
- [x] Extract aside template
- [x] Improve reverse deps queries, (ref #1508)
@homu
Copy link
Copy Markdown
Contributor

homu commented Dec 28, 2016

⌛ Testing commit 012c1e2 with merge 9769a74...

@homu
Copy link
Copy Markdown
Contributor

homu commented Dec 28, 2016

☀️ Test successful - status

@homu homu merged commit 012c1e2 into rubygems:master Dec 28, 2016
@spk spk deleted the expose-reverse-dependencies branch January 10, 2017 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.