diff --git a/app/controllers/packages_controller.rb b/app/controllers/packages_controller.rb index e00b9b15..9d367b6a 100644 --- a/app/controllers/packages_controller.rb +++ b/app/controllers/packages_controller.rb @@ -65,7 +65,12 @@ def dependent_packages end end - scope = @package.dependent_packages.includes(:registry) + if params[:latest].present? + scope = @package.latest_dependent_packages(kind: params[:kind]).includes(:registry) + else + scope = @package.dependent_packages(kind: params[:kind]).includes(:registry) + end + if params[:sort].present? || params[:order].present? sort = params[:sort] || 'updated_at' sort = "(repo_metadata ->> 'stargazers_count')::text::integer" if params[:sort] == 'stargazers_count' @@ -78,6 +83,8 @@ def dependent_packages scope = scope.order('latest_release_published_at DESC') end + @kinds = @package.dependent_package_kinds + @pagy, @dependent_packages = pagy_countless(scope) fresh_when(@dependent_packages, public: true) end diff --git a/app/views/packages/dependent_packages.html.erb b/app/views/packages/dependent_packages.html.erb index 3737efc9..2a621c10 100644 --- a/app/views/packages/dependent_packages.html.erb +++ b/app/views/packages/dependent_packages.html.erb @@ -6,8 +6,30 @@ <%= render 'tabs' %> <% if @dependent_packages.any? %> - <%= render @dependent_packages %> - <%== pagy_bootstrap_nav(@pagy) if @pagy.pages && @pagy.pages > 1 %> +
+
+ <%= render @dependent_packages %> + <%== pagy_bootstrap_nav(@pagy) if @pagy.pages && @pagy.pages > 1 %> +
+
+
+
+ Filter by kind +
+
+ + All kinds + + <% @kinds.each do |kind, count| %> + + <%= kind %> + <%= count %> + + <% end %> +
+
+
+
<% else %>