-
Notifications
You must be signed in to change notification settings - Fork 21.9k
Fix #50005 transform_job not accepting previewables #50006
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
Merged
jonathanhefner
merged 1 commit into
rails:main
from
nicowenterodt:preprocess_previewables
Nov 11, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
hi @jonathanhefner @nicowenterodt
thanks for your work.
I would like to point out that this test does not test that a
variant
has been created. it tests that the preview image has been generatedWhat I mean by that is that each
ActiveStorage::Blob
has ahas_one_attached :preview_image
which is another bloband right now
processed
only generates this blob, but not the variant that's associated withpreview_image
in my production app, I had to do this to preprocess a preview with its variants:
Adding the
key
call is a bit of hack, but it will not only generate thepreview_image
but also the variant associated with which is, in my opinion, what's expected when we add thepreprocessed: true
( the key that's returned is discarded, but it's the newly generated variant's key which i believe won't impact performance)I will try to create a PR. I'm also considering changing the
processed
method implementation, but I feel it's a bit complex ( I need to further read on how to check if an image variant has already been processed for a set of transformations)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'm creating a PR
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.
Hi @chaadow, thanks for your feedback.
So when I get it right this still does not really "preprocess" the actual variant you defined as a named variant like this:
So there is no error now within the
TransformJob
because the preview_image will be preprocessed successfully utilizing therepresentation
method. However the defined variant of the preview itself is not respected and so when you access it like this:... the actual variant of the preview is missing which leads to a new attachment generated on the fly which is not really the purpose of being "preprocssed".
Correct? I think I missed that because I focused too much on the
ActiveStorage::InvariableError
thrown within theTransformJob
itself not checking the actual "preprocssed" characteristic of the defined variant. Oops.@jonathanhefner Is this worth a new issue? Or shall we reopen #50005 ?
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've created a PR #50026
Uh oh!
There was an error while loading. Please reload this page.
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.
Sorry i've added my comment without seeing yours
@nicowenterodt that's 100% correct. Since I had to manually pre process big HEIC files on rails 7.0 ( with a custom HEIC previewer, but logic is similar for any
previewable
blob), I realized that both the preview image and its associated variant were generated on the fly, and it created a bit of an unpleasant/suboptimal user experience.I also realized that simply calling
processed
won't generate the variant. which led me to add thekey
callI would love your feedback on my PR. thanks!
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.
Thanks @chaadow. I will have a look.