-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
[ActiveStorage] Prevent AS::Preview#processed
to generate a variant for an empty transformation
#50046
[ActiveStorage] Prevent AS::Preview#processed
to generate a variant for an empty transformation
#50046
Conversation
b4d327a
to
2686bfb
Compare
332b7ea
to
df01397
Compare
7bb9a6b
to
d58c1b6
Compare
998f2f0
to
a4b36fe
Compare
a4b36fe
to
fd721c7
Compare
I've squashed and rebased with main. |
fd721c7
to
1a2e644
Compare
b0841d8
to
7493b6d
Compare
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.
I see that you recently pushed many documentation changes. Would you mind splitting those out into separate PRs unless they are directly related to this change? It makes things easier to review. Also, keep in mind that this is an optimization for a corner case, so I don't think we need to extensively document it (if at all).
7493b6d
to
f4a0bf5
Compare
@jonathanhefner I changed all of Moreover, contextually speaking, since it's a followup from our past Pull request that we co-authored, in which we changed I will revert and create another PR. Thanks again for the prompt and exhaustive review! |
if an empty hash is passed to a preview call (`blob.preview({})`) We go through the original preview instead of regenerating a variation based on the original preview image which would result in a performance penalty
f4a0bf5
to
eae1965
Compare
@jonathanhefner I've applied the last changes, squashed the commits, and rebased with main. |
Thank you, @chaadow! ✔️ |
Thanks from me as well. Very useful 👏 @chaadow @jonathanhefner |
|
||
preview.processed | ||
|
||
freeze_time { assert_equal blob.preview_image.url, preview.url } |
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.
@chaadow I've stumbled upon this now, why is this here? If I remove it the tests still pass for me.
Followup #50044 cc @jonathanhefner
Motivation / Background
if an empty hash is passed to a preview call (
blob.preview({})
) We go through the original preview instead of regenerating a variation based on the original preview image which would result in a performance penalty.Detail
Calls to
#url
or#key
would now use the originalblob.preview_image
instead of generating a variant that has an empty transformation.==> Resulting in saving both a
MiniMagic/vips
call. + a network/IO call to the storage serviceAdditional information
Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]