Skip to content

Commit af2ca96

Browse files
ENGCOM-6292: Remove old logic to make search by operation status possible #25569
2 parents cc11890 + b1bf07c commit af2ca96

File tree

4 files changed

+65
-19
lines changed

4 files changed

+65
-19
lines changed

app/code/Magento/AsynchronousOperations/Model/BulkStatus.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,22 +87,6 @@ public function getFailedOperationsByBulkId($bulkUuid, $failureType = null)
8787
*/
8888
public function getOperationsCountByBulkIdAndStatus($bulkUuid, $status)
8989
{
90-
if ($status === OperationInterface::STATUS_TYPE_OPEN) {
91-
/**
92-
* Total number of operations that has been scheduled within the given bulk
93-
*/
94-
$allOperationsQty = $this->getOperationCount($bulkUuid);
95-
96-
/**
97-
* Number of operations that has been processed (i.e. operations with any status but 'open')
98-
*/
99-
$allProcessedOperationsQty = (int)$this->operationCollectionFactory->create()
100-
->addFieldToFilter('bulk_uuid', $bulkUuid)
101-
->getSize();
102-
103-
return $allOperationsQty - $allProcessedOperationsQty;
104-
}
105-
10690
/** @var \Magento\AsynchronousOperations\Model\ResourceModel\Operation\Collection $collection */
10791
$collection = $this->operationCollectionFactory->create();
10892
return $collection->addFieldToFilter('bulk_uuid', $bulkUuid)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\AsynchronousOperations\Api;
10+
11+
use Magento\TestFramework\TestCase\WebapiAbstract;
12+
use Magento\Framework\Bulk\OperationInterface;
13+
14+
class BulkStatusInterfaceTest extends WebapiAbstract
15+
{
16+
const RESOURCE_PATH = '/V1/bulk/';
17+
const SERVICE_NAME = 'asynchronousOperationsBulkStatusV1';
18+
const GET_COUNT_OPERATION_NAME = "GetOperationsCountByBulkIdAndStatus";
19+
const TEST_UUID = "bulk-uuid-searchable-6";
20+
21+
/**
22+
* @magentoApiDataFixture Magento/AsynchronousOperations/_files/operation_searchable.php
23+
*/
24+
public function testGetListByBulkStartTime()
25+
{
26+
$resourcePath = self::RESOURCE_PATH
27+
. self::TEST_UUID
28+
. "/operation-status/"
29+
. OperationInterface::STATUS_TYPE_OPEN;
30+
$serviceInfo = [
31+
'rest' => [
32+
'resourcePath' => $resourcePath,
33+
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_GET
34+
],
35+
'soap' => [
36+
'service' => self::SERVICE_NAME,
37+
'serviceVersion' => 'V1',
38+
'operation' => self::SERVICE_NAME . self::GET_COUNT_OPERATION_NAME
39+
],
40+
];
41+
$qty = $this->_webApiCall(
42+
$serviceInfo,
43+
['bulkUuid' => self::TEST_UUID, 'status' => OperationInterface::STATUS_TYPE_OPEN]
44+
);
45+
$this->assertEquals(2, $qty);
46+
}
47+
}

dev/tests/api-functional/testsuite/Magento/AsynchronousOperations/Api/OperationRepositoryInterfaceTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public function testGetListByBulkStartTime()
5757
$this->assertArrayHasKey('items', $response);
5858

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

6363
foreach ($response['items'] as $item) {
6464
$this->assertEquals('bulk-uuid-searchable-6', $item['bulk_uuid']);

dev/tests/integration/testsuite/Magento/AsynchronousOperations/_files/operation_searchable.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,22 @@
5252
'error_code' => 2222,
5353
'result_message' => 'Entity with ID=4 does not exist',
5454
],
55-
55+
[
56+
'bulk_uuid' => 'bulk-uuid-searchable-6',
57+
'topic_name' => 'topic-5',
58+
'serialized_data' => json_encode(['entity_id' => 5]),
59+
'status' => OperationInterface::STATUS_TYPE_OPEN,
60+
'error_code' => null,
61+
'result_message' => '',
62+
],
63+
[
64+
'bulk_uuid' => 'bulk-uuid-searchable-6',
65+
'topic_name' => 'topic-5',
66+
'serialized_data' => json_encode(['entity_id' => 5]),
67+
'status' => OperationInterface::STATUS_TYPE_OPEN,
68+
'error_code' => null,
69+
'result_message' => '',
70+
]
5671
];
5772

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

0 commit comments

Comments
 (0)