From 34e3489e3a3495f66fa08f7a89c282fed6faec0a Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Mon, 29 Nov 2021 20:10:37 -0300 Subject: [PATCH] 18484: Makes a list request on collectionService.get(). To avoid getting a whole collection record with its manifest_text field, we use the list request with a uuid filter. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- .../collection-service.test.ts | 18 ++++++++++++++++++ .../collection-service/collection-service.ts | 9 +++++++++ src/services/common-service/common-service.ts | 10 ++++++---- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/services/collection-service/collection-service.test.ts b/src/services/collection-service/collection-service.test.ts index c0aa85f1..1b0130c7 100644 --- a/src/services/collection-service/collection-service.test.ts +++ b/src/services/collection-service/collection-service.test.ts @@ -30,6 +30,24 @@ describe('collection-service', () => { collectionService.update = jest.fn(); }); + describe('get', () => { + it('should make a list request with uuid filtering', async () => { + serverApi.get = jest.fn(() => Promise.resolve( + { data: { items: [{}] } } + )); + const uuid = 'zzzzz-4zz18-0123456789abcde' + await collectionService.get(uuid); + expect(serverApi.get).toHaveBeenCalledWith( + '/collections', { + params: { + filters: `[["uuid","=","zzzzz-4zz18-0123456789abcde"]]`, + order: undefined + }, + } + ); + }); + }); + describe('update', () => { it('should call put selecting updated fields + others', async () => { serverApi.put = jest.fn(() => Promise.resolve({ data: {} })); diff --git a/src/services/collection-service/collection-service.ts b/src/services/collection-service/collection-service.ts index 48e797c5..43041ccd 100644 --- a/src/services/collection-service/collection-service.ts +++ b/src/services/collection-service/collection-service.ts @@ -11,6 +11,7 @@ import { extractFilesData } from "./collection-service-files-response"; import { TrashableResourceService } from "services/common-service/trashable-resource-service"; import { ApiActions } from "services/api/api-actions"; import { customEncodeURI } from "common/url"; +import { FilterBuilder } from "services/api/filter-builder"; export type UploadProgress = (fileId: number, loaded: number, total: number, currentTime: number) => void; @@ -28,6 +29,14 @@ export class CollectionService extends TrashableResourceService) { return super.create({ ...data, preserveVersion: true }); } diff --git a/src/services/common-service/common-service.ts b/src/services/common-service/common-service.ts index 82777342..b5dd1a08 100644 --- a/src/services/common-service/common-service.ts +++ b/src/services/common-service/common-service.ts @@ -68,7 +68,7 @@ export class CommonService { } } - private validateUuid(uuid: string) { + protected validateUuid(uuid: string) { if (uuid === "") { throw new Error('UUID cannot be empty string'); } @@ -124,7 +124,7 @@ export class CommonService { ); } - list(args: ListArguments = {}): Promise> { + list(args: ListArguments = {}, showErrors?: boolean): Promise> { const { filters, order, ...other } = args; const params = { ...CommonService.mapKeys(snakeCase)(other), @@ -135,7 +135,8 @@ export class CommonService { if (QueryString.stringify(params).length <= 1500) { return CommonService.defaultResponse( this.serverApi.get(`/${this.resourceType}`, { params }), - this.actions + this.actions, + showErrors ); } else { // Using the POST special case to avoid URI length 414 errors. @@ -152,7 +153,8 @@ export class CommonService { _method: 'GET' } }), - this.actions + this.actions, + showErrors ); } } -- 2.30.2