Skip to content

Commit

Permalink
perf: premier test du champ "fields" sur les collections API entrepôt
Browse files Browse the repository at this point in the history
  • Loading branch information
ocruze committed Nov 26, 2024
1 parent 1c3602a commit d6b2d89
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/Controller/Entrepot/DatasheetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ public function __construct(
#[Route('', name: 'get_list', methods: ['GET'])]
public function getDatasheetList(string $datastoreId): JsonResponse
{
$uploads = $this->uploadApiService->getAllDetailed($datastoreId, [
$uploads = $this->uploadApiService->getAll($datastoreId, [
'sort' => 'lastEvent,desc',
'fields' => ['tags'],
]);

$uploadDatasheetNames = array_map(function ($upload) {
Expand All @@ -52,8 +53,9 @@ public function getDatasheetList(string $datastoreId): JsonResponse
}
}, $uploads);

$storedDataList = $this->storedDataApiService->getAllDetailed($datastoreId, [
$storedDataList = $this->storedDataApiService->getAll($datastoreId, [
'sort' => 'lastEvent,desc',
'fields' => ['tags'],
]);

$storedDataDatasheetNames = array_map(function ($storedData) {
Expand Down
11 changes: 9 additions & 2 deletions src/Services/EntrepotApi/StoredDataApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct(
LoggerInterface $logger,
private ProcessingApiService $processingApiService,
private ConfigurationApiService $configurationApiService,
private AnnexeApiService $annexeApiService
private AnnexeApiService $annexeApiService,
) {
parent::__construct($httpClient, $parameters, $filesystem, $requestStack, $logger);
}
Expand All @@ -33,7 +33,14 @@ public function getAll(string $datastoreId, array $query = []): array
$query['sort'] = 'lastEvent,desc';
}

return $this->requestAll("datastores/$datastoreId/stored_data", $query);
/*
* pour transformer "sort=lastEvent,desc&fields[0]=field1&fields[1]=field2" en "sort=lastEvent,desc&fields=field1&fields=field2"
* l'API entrepôt ignore le premier format
*/
$queryString = urldecode(http_build_query($query));
$queryString = preg_replace('/\[\d+\]/', '', $queryString);

return $this->requestAll("datastores/$datastoreId/stored_data?{$queryString}");
}

/**
Expand Down
9 changes: 8 additions & 1 deletion src/Services/EntrepotApi/UploadApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ public function getAll(string $datastoreId, array $query = []): array
$query['sort'] = 'lastEvent,desc';
}

return $this->requestAll("datastores/$datastoreId/uploads", $query);
/*
* pour transformer "sort=lastEvent,desc&fields[0]=field1&fields[1]=field2" en "sort=lastEvent,desc&fields=field1&fields=field2"
* l'API entrepôt ignore le premier format
*/
$queryString = urldecode(http_build_query($query));
$queryString = preg_replace('/\[\d+\]/', '', $queryString);

return $this->requestAll("datastores/$datastoreId/uploads?{$queryString}");
}

/**
Expand Down

0 comments on commit d6b2d89

Please sign in to comment.