-
-
Notifications
You must be signed in to change notification settings - Fork 933
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fetch oldest authored_at correctly instead of oldest authored_at per page #4460
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,19 @@ class Version < ApplicationRecord # rubocop:disable Metrics/ClassLength | |
validate :metadata_attribute_length | ||
validate :no_dashes_in_version_number, on: :create | ||
|
||
scope :oldest_authored_at, lambda { | ||
minimum( | ||
<<~SQL.squish | ||
CASE WHEN DATE(created_at) = '#{RUBYGEMS_IMPORT_DATE}' | ||
AND built_at <= created_at THEN | ||
built_at | ||
ELSE | ||
created_at | ||
END | ||
SQL | ||
)&.in_time_zone | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The minimum query by itself returns a But I don't think it is strictly necessary because the equality check in the tests pass without the conversion and the rendering on the versions page is the same as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there is no timezone conversion currently happening in the codebase and all times are just printed to the page as stored in DB. IMHO not needed as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. makes sense, removed |
||
} | ||
|
||
class AuthorType < ActiveModel::Type::String | ||
def cast_value(value) | ||
if value.is_a?(Array) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to make this class level method instead of
scope
? Scope is usually used to return collection (is chainable).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah that makes sense, changed to a class method and moved closer to
#authored_at