From 3941c330d611f386d71c07466a05a3ec52254d0f Mon Sep 17 00:00:00 2001 From: Alvaro Sanchez Date: Tue, 20 Feb 2024 17:03:53 -0600 Subject: [PATCH] The rubygem partial displays the latest release date --- app/assets/stylesheets/modules/gems.css | 2 +- app/controllers/searches_controller.rb | 5 +++-- app/views/rubygems/_rubygem.html.erb | 7 ++++++- app/views/searches/show.html.erb | 4 ++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/assets/stylesheets/modules/gems.css b/app/assets/stylesheets/modules/gems.css index 26da7e39922..6404e551e1a 100644 --- a/app/assets/stylesheets/modules/gems.css +++ b/app/assets/stylesheets/modules/gems.css @@ -92,7 +92,7 @@ float: right; text-align: right; } } -.gems__gem__version { +.gems__gem__version, .gems__gem__latest__release__date { margin-left: 10px; font-style: italic; font-weight: 300; diff --git a/app/controllers/searches_controller.rb b/app/controllers/searches_controller.rb index 6cf5b058b32..e88fbc6cf37 100644 --- a/app/controllers/searches_controller.rb +++ b/app/controllers/searches_controller.rb @@ -3,9 +3,10 @@ class SearchesController < ApplicationController def show return unless params[:query].is_a?(String) - @error_msg, @gems = ElasticSearcher.new(params[:query], page: @page).search + @error_msg, @elastic_results = ElasticSearcher.new(params[:query], page: @page).search - return unless @gems + return unless @elastic_results + @gems = Rubygem.where(id: @elastic_results.map(&:id)).with_versions set_total_pages if @gems.total_count > Gemcutter::SEARCH_MAX_PAGES * Rubygem.default_per_page exact_match = Rubygem.name_is(params[:query]).first @yanked_gem = exact_match unless exact_match&.indexed_versions? diff --git a/app/views/rubygems/_rubygem.html.erb b/app/views/rubygems/_rubygem.html.erb index c3a4f8f714e..49e522b63aa 100644 --- a/app/views/rubygems/_rubygem.html.erb +++ b/app/views/rubygems/_rubygem.html.erb @@ -2,7 +2,12 @@

<%= rubygem.name %> - <%= latest_version_number(rubygem) %> + + <%= latest_version_number(rubygem) %> + + + <%= version_date_tag(rubygem.latest_version) %> +

<%= short_info(rubygem) %>

diff --git a/app/views/searches/show.html.erb b/app/views/searches/show.html.erb index 59b0c68a537..a21288cb636 100644 --- a/app/views/searches/show.html.erb +++ b/app/views/searches/show.html.erb @@ -25,7 +25,7 @@ <% @subtitle = t('.subtitle', :query => content_tag(:em, h(params[:query]))) %>
-

<%= page_entries_info(@gems, :entry_name => 'gem').html_safe %>

+

<%= page_entries_info(@elastic_results, :entry_name => 'gem').html_safe %>

<%= render partial: 'aggregations', locals: { gems: @gems } %> @@ -44,7 +44,7 @@ <% if @gems.present? %> <%= render partial: 'rubygems/rubygem', collection: @gems %> - <%= paginate @gems %> + <%= paginate @elastic_results %> <% end %> <% end %> <% end %>