Skip to content

fix(tasks): pre-generate thumbnails for active_storage#4037

Draft
tvdeyen wants to merge 1 commit into
mainfrom
ingredient-thumbnail-crops
Draft

fix(tasks): pre-generate thumbnails for active_storage#4037
tvdeyen wants to merge 1 commit into
mainfrom
ingredient-thumbnail-crops

Conversation

@tvdeyen

@tvdeyen tvdeyen commented Jul 2, 2026

Copy link
Copy Markdown
Member

What is this pull request for?

The alchemy:generate:thumbnails task was written for Dragonfly: it called PictureThumb.generate_thumbs! directly and warmed ingredient variants by requesting their urls, both of which only persist a thumbnail as a Dragonfly side effect.

Under the now-default active_storage adapter it generated nothing and its :thumbs preload referenced an association that does not exist there. Move the logic into an Alchemy::GenerateThumbnails service that branches on the configured storage adapter and materializes each variant inline, so existing pictures and their ingredient crop and srcset variants are warmed on both adapters.

Checklist

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have added tests to cover this change

@tvdeyen tvdeyen added this to the 8.4 milestone Jul 2, 2026
@tvdeyen tvdeyen requested a review from a team as a code owner July 2, 2026 12:57
@tvdeyen tvdeyen added the enhancement New feature or enhancement label Jul 2, 2026
@tvdeyen tvdeyen force-pushed the ingredient-thumbnail-crops branch from eb81251 to 516b415 Compare July 2, 2026 12:58
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.00%. Comparing base (1949414) to head (1bf2c67).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4037   +/-   ##
=======================================
  Coverage   97.99%   98.00%           
=======================================
  Files         346      347    +1     
  Lines        8995     9027   +32     
=======================================
+ Hits         8815     8847   +32     
  Misses        180      180           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tvdeyen tvdeyen force-pushed the ingredient-thumbnail-crops branch from 516b415 to 0ff3cfc Compare July 2, 2026 13:25
The alchemy:generate:thumbnails task was written for Dragonfly: it called
PictureThumb.generate_thumbs! directly and warmed ingredient variants by
requesting their urls, both of which only persist a thumbnail as a Dragonfly
side effect. Under the now-default active_storage adapter it generated nothing
and its :thumbs preload referenced an association that does not exist there.
Move the logic into an Alchemy::GenerateThumbnails service that branches on the
configured storage adapter and materializes each variant inline, so existing
pictures and their ingredient crop and srcset variants are warmed on both
adapters. The service yields each processed record so the rake task can report
progress during a long running generation run.
@tvdeyen tvdeyen force-pushed the ingredient-thumbnail-crops branch from 0ff3cfc to 1bf2c67 Compare July 2, 2026 13:32
@tvdeyen

tvdeyen commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

Let's use ActiveJob and add a async argument to the rake task, so if needed we can background the thumbnail generation

@tvdeyen tvdeyen marked this pull request as draft July 6, 2026 10:20
@tvdeyen tvdeyen self-assigned this Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant