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.php is 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

Command icon 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

rajeshreeputra created an issue. See original summary.

rajeshreeputra’s picture

rajeshreeputra’s picture

Status: Needs work » Needs review

Requesting review.

rohan-sinha’s picture

Status: Needs review » Reviewed & tested by the community

lgtm.

  • rajeshreeputra committed bdb6fb25 on 1.1.x
    Resolve #3590852 "Improve Acquia DAM asset update Drush command as per...
rajeshreeputra’s picture

Status: Reviewed & tested by the community » Fixed

MR merged!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.