From b3f10e3c7f3d065ff1100adb67d87012c5881b99 Mon Sep 17 00:00:00 2001 From: Alvaro Sanchez Date: Sun, 25 Feb 2024 20:16:46 -0600 Subject: [PATCH] The rubygem partial displays the latest release date --- app/helpers/rubygems_helper.rb | 15 ++++++++++++++- app/views/rubygems/_rubygem.html.erb | 1 + lib/elastic_searcher.rb | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/helpers/rubygems_helper.rb b/app/helpers/rubygems_helper.rb index a6f2db4279c..1bc9c750c17 100644 --- a/app/helpers/rubygems_helper.rb +++ b/app/helpers/rubygems_helper.rb @@ -161,9 +161,16 @@ def show_all_versions_link?(rubygem) rubygem.versions_count > 5 || rubygem.yanked_versions? end + def latest_release_date(rubygem) + latest = latest_version(rubygem) + return version_date_tag(latest) if latest.present? + + tag.small("- #{nice_date_for(rubygem.updated)}", class: "gem__version__date") if rubygem.respond_to?(:updated) && rubygem.updated.present? + end + def latest_version_number(rubygem) return rubygem.version if rubygem.respond_to?(:version) - (rubygem.latest_version || rubygem.versions.last)&.number + latest_version(rubygem)&.number end def link_to_github(rubygem) @@ -218,4 +225,10 @@ def copy_field_tag(name, value) } ) end + + private + + def latest_version(rubygem) + (rubygem.latest_version || rubygem.versions.last) + end end diff --git a/app/views/rubygems/_rubygem.html.erb b/app/views/rubygems/_rubygem.html.erb index c3a4f8f714e..a309ad70a02 100644 --- a/app/views/rubygems/_rubygem.html.erb +++ b/app/views/rubygems/_rubygem.html.erb @@ -3,6 +3,7 @@

<%= rubygem.name %> <%= latest_version_number(rubygem) %> + <%= latest_release_date(rubygem) %>

<%= short_info(rubygem) %>

diff --git a/lib/elastic_searcher.rb b/lib/elastic_searcher.rb index 8436e740ccb..3f6ba9ce668 100644 --- a/lib/elastic_searcher.rb +++ b/lib/elastic_searcher.rb @@ -152,6 +152,7 @@ def ui_source summary description downloads + updated version] end end