Skip to content

Remove old logic to make search by operation status possible #25569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions app/code/Magento/AsynchronousOperations/Model/BulkStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,6 @@ public function getFailedOperationsByBulkId($bulkUuid, $failureType = null)
*/
public function getOperationsCountByBulkIdAndStatus($bulkUuid, $status)
{
if ($status === OperationInterface::STATUS_TYPE_OPEN) {
/**
* Total number of operations that has been scheduled within the given bulk
*/
$allOperationsQty = $this->getOperationCount($bulkUuid);

/**
* Number of operations that has been processed (i.e. operations with any status but 'open')
*/
$allProcessedOperationsQty = (int)$this->operationCollectionFactory->create()
->addFieldToFilter('bulk_uuid', $bulkUuid)
->getSize();

return $allOperationsQty - $allProcessedOperationsQty;
}

/** @var \Magento\AsynchronousOperations\Model\ResourceModel\Operation\Collection $collection */
$collection = $this->operationCollectionFactory->create();
return $collection->addFieldToFilter('bulk_uuid', $bulkUuid)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Magento\AsynchronousOperations\Api;

use Magento\TestFramework\TestCase\WebapiAbstract;
use Magento\Framework\Bulk\OperationInterface;

class BulkStatusInterfaceTest extends WebapiAbstract
{
const RESOURCE_PATH = '/V1/bulk/';
const SERVICE_NAME = 'asynchronousOperationsBulkStatusV1';
const GET_COUNT_OPERATION_NAME = "GetOperationsCountByBulkIdAndStatus";
const TEST_UUID = "bulk-uuid-searchable-6";

/**
* @magentoApiDataFixture Magento/AsynchronousOperations/_files/operation_searchable.php
*/
public function testGetListByBulkStartTime()
{
$resourcePath = self::RESOURCE_PATH
. self::TEST_UUID
. "/operation-status/"
. OperationInterface::STATUS_TYPE_OPEN;
$serviceInfo = [
'rest' => [
'resourcePath' => $resourcePath,
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET
],
'soap' => [
'service' => self::SERVICE_NAME,
'serviceVersion' => 'V1',
'operation' => self::SERVICE_NAME . self::GET_COUNT_OPERATION_NAME
],
];
$qty = $this->_webApiCall(
$serviceInfo,
['bulkUuid' => self::TEST_UUID, 'status' => OperationInterface::STATUS_TYPE_OPEN]
);
$this->assertEquals(2, $qty);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public function testGetListByBulkStartTime()
$this->assertArrayHasKey('items', $response);

$this->assertEquals($searchCriteria['searchCriteria'], $response['search_criteria']);
$this->assertEquals(3, $response['total_count']);
$this->assertEquals(3, count($response['items']));
$this->assertEquals(5, $response['total_count']);
$this->assertEquals(5, count($response['items']));

foreach ($response['items'] as $item) {
$this->assertEquals('bulk-uuid-searchable-6', $item['bulk_uuid']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,22 @@
'error_code' => 2222,
'result_message' => 'Entity with ID=4 does not exist',
],

[
'bulk_uuid' => 'bulk-uuid-searchable-6',
'topic_name' => 'topic-5',
'serialized_data' => json_encode(['entity_id' => 5]),
'status' => OperationInterface::STATUS_TYPE_OPEN,
'error_code' => null,
'result_message' => '',
],
[
'bulk_uuid' => 'bulk-uuid-searchable-6',
'topic_name' => 'topic-5',
'serialized_data' => json_encode(['entity_id' => 5]),
'status' => OperationInterface::STATUS_TYPE_OPEN,
'error_code' => null,
'result_message' => '',
]
];

$bulkQuery = "INSERT INTO {$bulkTable} (`uuid`, `user_id`, `description`, `operation_count`, `start_time`)"
Expand Down