From a925e35676fde38ed143b908dc6f614da182111d Mon Sep 17 00:00:00 2001 From: JeraldJF Date: Mon, 20 Jan 2025 13:21:17 +0530 Subject: [PATCH] fix: #OBS-I452 method change --- .../controllers/DataIngestion/DataIngestionController.ts | 2 +- api-service/src/controllers/DataOut/DataOutController.ts | 2 +- api-service/src/services/DatasetService.ts | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/api-service/src/controllers/DataIngestion/DataIngestionController.ts b/api-service/src/controllers/DataIngestion/DataIngestionController.ts index 85b25b26..e8f6c813 100644 --- a/api-service/src/controllers/DataIngestion/DataIngestionController.ts +++ b/api-service/src/controllers/DataIngestion/DataIngestionController.ts @@ -21,7 +21,7 @@ const requestValidation = async (req: Request) => { let dataset = await datasetService.getDatasetWithAlias(datasetKey, ["id", "entry_topic", "api_version", "dataset_config", "dataset_id", "extraction_config"], true) //dataset check considering datasetKey as alias name if (_.isEmpty(dataset)) { logger.info({ apiId, message: `Dataset with alias '${datasetKey}' does not exist` }) - dataset = await datasetService.getDataset(datasetKey, ["id", "entry_topic", "api_version", "dataset_config", "dataset_id", "extraction_config"], true) //dataset check considering datasetKey as dataset_id + dataset = await datasetService.getLiveDataset(datasetKey, ["id", "entry_topic", "api_version", "dataset_config", "dataset_id", "extraction_config"], true) //dataset check considering datasetKey as dataset_id if (_.isEmpty(dataset)) { throw obsrvError(datasetKey, "DATASET_NOT_FOUND", `Dataset with id/alias name '${datasetKey}' not found`, "NOT_FOUND", 404) } diff --git a/api-service/src/controllers/DataOut/DataOutController.ts b/api-service/src/controllers/DataOut/DataOutController.ts index 8b3f82f2..e5db929c 100644 --- a/api-service/src/controllers/DataOut/DataOutController.ts +++ b/api-service/src/controllers/DataOut/DataOutController.ts @@ -20,7 +20,7 @@ const requestValidation = async (req: Request) => { let dataset = await datasetService.getDatasetWithAlias(datasetKey, ["dataset_id"], true) //dataset check considering datasetKey as alias name if (_.isEmpty(dataset)) { logger.info({ apiId, message: `Dataset with alias '${datasetKey}' does not exist` }) - dataset = await datasetService.getDataset(datasetKey, ["dataset_id"], true) //dataset check considering datasetKey as dataset_id + dataset = await datasetService.getLiveDataset(datasetKey, ["dataset_id"], true) //dataset check considering datasetKey as dataset_id if (_.isEmpty(dataset)) { throw obsrvError(datasetKey, "DATASET_NOT_FOUND", `Dataset with id/alias name '${datasetKey}' not found`, "NOT_FOUND", 404) } diff --git a/api-service/src/services/DatasetService.ts b/api-service/src/services/DatasetService.ts index 54c386ca..65bc00b9 100644 --- a/api-service/src/services/DatasetService.ts +++ b/api-service/src/services/DatasetService.ts @@ -26,8 +26,12 @@ class DatasetService { return Dataset.findOne({ where: { id: datasetId }, attributes, raw: raw }); } + getLiveDataset = async (datasetId: string, attributes?: string[], raw = false): Promise => { + return Dataset.findOne({ where: { id: datasetId, status: DatasetStatus.Live }, attributes, raw: raw }); + } + getDatasetWithAlias = async (alias: string, attributes?: string[], raw = false): Promise => { - return Dataset.findOne({ where: { alias }, attributes, raw: raw }); + return Dataset.findOne({ where: { alias, status: DatasetStatus.Live }, attributes, raw: raw }); } findDatasets = async (where?: Record, attributes?: string[], order?: any): Promise => {