Refactor Drush asset update commands to use efficient DAM API batch processing with optional finalized version checking.
Problem/Motivation
Currently, the Drush asset update commands (acquia-dam:queue-update-assets) use an inefficient approach:
- Individual API calls per media item: Each media item triggers separate API calls via
AssetUpdateChecker::checkAssets(), leading to N+1 query problems - Code duplication: The efficient batch API pattern implemented in
Cron.phpis not available to Drush commands - Limited flexibility: No way to fetch all assets from DAM without individually checking each media item
- Missing edge case coverage: Cannot check for finalized version changes that DAM doesn't report in
lastEditDate
Proposed resolution
Refactor the asset update workflow to consolidate logic in AssetUpdater service and provide a unified syncAssets() method that:
- Fetches assets from DAM API in batch (same efficient approach as cron)
- Categorizes into unpublish/update groups using search response data
- Processes unpublish operations immediately
- Queues update operations in batch
- Optionally checks remaining media for finalized version mismatches
New Drush Command Behavior
Without --finalized-version:
drush acquia-dam:queue-update-assets --since=0
- Fetches ALL assets from DAM API (or filtered by timestamp)
- Categorizes and queues based on DAM data
- Fast and efficient - uses batch API calls
With --finalized-version:
drush acquia-dam:queue-update-assets --since=0 --finalized-version
- First, processes all DAM-reported changes (as above)
- Then, checks remaining media items for finalized version mismatches
- Most thorough - catches edge cases where finalized version changes without DAM reporting it
Issue fork acquia_dam-3590852
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
rajeshreeputraRelated issue added.
Comment #4
rajeshreeputraRequesting review.
Comment #5
rohan-sinha commentedlgtm.
Comment #7
rajeshreeputraMR merged!