diff --git a/app/controllers/versions_controller.rb b/app/controllers/versions_controller.rb index e5bdfe34f84..597afd6e51c 100644 --- a/app/controllers/versions_controller.rb +++ b/app/controllers/versions_controller.rb @@ -3,6 +3,7 @@ class VersionsController < ApplicationController def index set_page + @oldest_version_date = @rubygem.versions.oldest_authored_at @versions = @rubygem.versions.by_position.page(@page).per(Gemcutter::VERSIONS_PER_PAGE) end diff --git a/app/models/version.rb b/app/models/version.rb index 32e61390acc..5e9bc1abe29 100644 --- a/app/models/version.rb +++ b/app/models/version.rb @@ -212,6 +212,19 @@ def rely_on_built_at? built_at && built_at <= RUBYGEMS_IMPORT_DATE end + def self.oldest_authored_at + minimum( + <<~SQL.squish + CASE WHEN DATE(created_at) = '#{RUBYGEMS_IMPORT_DATE}' + AND built_at <= created_at THEN + built_at + ELSE + created_at + END + SQL + ) + end + def refresh_rubygem_indexed rubygem.refresh_indexed! end diff --git a/app/views/versions/index.html.erb b/app/views/versions/index.html.erb index 94620b1f37d..3a8a919d373 100644 --- a/app/views/versions/index.html.erb +++ b/app/views/versions/index.html.erb @@ -4,7 +4,7 @@

<%= t('.not_hosted_notice') %>

<% else %> -

<%= t('.versions_since', :count => @versions.total_count, :since => nice_date_for(@versions.map(&:authored_at).min)) %>:

+

<%= t('.versions_since', :count => @versions.total_count, :since => nice_date_for(@oldest_version_date)) %>: