diff --git a/.env.example b/.env.example index 869d056e4..4e401ec8c 100644 --- a/.env.example +++ b/.env.example @@ -64,7 +64,6 @@ OIDC_USERQUERY_OPERATOR=<"or"|"and"> OIDC_USERQUERY_FILTER="username:username, email:email" ELASTICSEARCH_ENABLED=<"yes"|"no"> -APP_PORT=3003 STACK_VERSION="8.8.2" CLUSTER_NAME="es-cluster" MEM_LIMIT="4G" diff --git a/src/datasets/datasets.controller.ts b/src/datasets/datasets.controller.ts index 99fdff3dc..3cb1a5ea2 100644 --- a/src/datasets/datasets.controller.ts +++ b/src/datasets/datasets.controller.ts @@ -178,10 +178,11 @@ export class DatasetsController { DatasetClass, ); + if (!mergedFilters.where) { + mergedFilters.where = {}; + } + if (!canViewAny) { - if (!mergedFilters.where) { - mergedFilters.where = {}; - } if (canViewAccess) { mergedFilters.where["$or"] = [ { ownerGroup: { $in: user.currentGroups } }, @@ -196,6 +197,10 @@ export class DatasetsController { } } + mergedFilters.where = this.convertObsoleteWhereFilterToCurrentSchema( + mergedFilters.where, + ); + return mergedFilters; } @@ -396,6 +401,27 @@ export class DatasetsController { return dataset; } + convertObsoleteWhereFilterToCurrentSchema( + whereFilter: Record, + ): IFilters { + if ("proposalId" in whereFilter) { + whereFilter.proposalIds = whereFilter.proposalId; + delete whereFilter.proposalId; + } + if ("sampleId" in whereFilter) { + whereFilter.sampleIds = whereFilter.sampleId; + delete whereFilter.sampleId; + } + if ("instrumentId" in whereFilter) { + whereFilter.instrumentIds = whereFilter.instrumentId; + delete whereFilter.instrumentId; + } + if ("principalInvestigator" in whereFilter) { + whereFilter.investigator = whereFilter.principalInvestigator; + delete whereFilter.principalInvestigator; + } + return whereFilter; + } convertObsoleteToCurrentSchema( inputObsoleteDataset: | CreateRawDatasetObsoleteDto