CalculatedStatusSql.php 858 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\AsynchronousOperations\Model\BulkStatus;
  7. use Magento\AsynchronousOperations\Api\Data\BulkSummaryInterface;
  8. class CalculatedStatusSql
  9. {
  10. /**
  11. * Get sql to calculate bulk status
  12. *
  13. * @param string $operationTableName
  14. * @return \Zend_Db_Expr
  15. */
  16. public function get($operationTableName)
  17. {
  18. return new \Zend_Db_Expr(
  19. '(IF(
  20. (SELECT count(*)
  21. FROM ' . $operationTableName . '
  22. WHERE bulk_uuid = main_table.uuid
  23. ) = 0,
  24. ' . BulkSummaryInterface::NOT_STARTED . ',
  25. (SELECT MAX(status) FROM ' . $operationTableName . ' WHERE bulk_uuid = main_table.uuid)
  26. ))'
  27. );
  28. }
  29. }