Skip to content
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

Correctly calculate last_modified_index when the @products scope is u… #25

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mrbrdo
Copy link
Contributor

@mrbrdo mrbrdo commented Nov 6, 2022

…sing GROUP BY

In this case, maximum(:updated_at) is not a single value but rather a hash.

Basically I just added handling the possible Hash result of #maximum.

…sing GROUP BY

In this case, maximum(:updated_at) is not a single value but rather a hash.
@@ -107,7 +107,15 @@ def etag_show
alias product_etag etag_show

def last_modified_index
products_last_modified = @products.maximum(:updated_at)&.utc if @products.respond_to?(:maximum)
if @products.respond_to?(:maximum)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrbrdo just wondering - are there any cases where @products won't respond to .maximum?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so (except if @products is nil but I don't think that's an allowed state). I didn't add that if, just kept it from before (was at end of line). And git blame shows it being copied around from another place, I didn't dig deeper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants