diff --git a/src/Controller/Entrepot/DatasheetController.php b/src/Controller/Entrepot/DatasheetController.php index 93926e51..32838ea7 100644 --- a/src/Controller/Entrepot/DatasheetController.php +++ b/src/Controller/Entrepot/DatasheetController.php @@ -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) { @@ -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) { diff --git a/src/Services/EntrepotApi/StoredDataApiService.php b/src/Services/EntrepotApi/StoredDataApiService.php index 1ea76aac..2758b9a8 100644 --- a/src/Services/EntrepotApi/StoredDataApiService.php +++ b/src/Services/EntrepotApi/StoredDataApiService.php @@ -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); } @@ -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}"); } /** diff --git a/src/Services/EntrepotApi/UploadApiService.php b/src/Services/EntrepotApi/UploadApiService.php index 21ca8618..fcb988f8 100644 --- a/src/Services/EntrepotApi/UploadApiService.php +++ b/src/Services/EntrepotApi/UploadApiService.php @@ -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}"); } /**