Skip to content
This repository was archived by the owner on Feb 7, 2026. It is now read-only.

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

Open
mrbrdo wants to merge 1 commit intospree:mainfrom
mrbrdo:fix_last_modified_products_list
Open

Correctly calculate last_modified_index when the @products scope is u…#25
mrbrdo wants to merge 1 commit intospree:mainfrom
mrbrdo:fix_last_modified_products_list

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.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants