Select rows from c_domain_build_queue with image_retry_count < 3 and chosen image_inspection status, then (optionally) reset them to rebuild.
c_domain_build_queue
image_retry_count < 3
image_inspection
image_retry_count < 3 AND image_inspection IN (2,3)
Example (both statuses, no filters, perform updates): /usr/bin/curl -s "https://YOURHOST/cp/image_quality_check_rebuild.php?status=both&dry=0"
/usr/bin/curl -s "https://YOURHOST/cp/image_quality_check_rebuild.php?status=both&dry=0"