Skip to content

Commit

Permalink
fix: #OBS-I452 method change
Browse files Browse the repository at this point in the history
  • Loading branch information
JeraldJF committed Jan 20, 2025
1 parent 1480ce1 commit a925e35
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion api-service/src/controllers/DataOut/DataOutController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
6 changes: 5 additions & 1 deletion api-service/src/services/DatasetService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ class DatasetService {
return Dataset.findOne({ where: { id: datasetId }, attributes, raw: raw });
}

getLiveDataset = async (datasetId: string, attributes?: string[], raw = false): Promise<any> => {
return Dataset.findOne({ where: { id: datasetId, status: DatasetStatus.Live }, attributes, raw: raw });
}

getDatasetWithAlias = async (alias: string, attributes?: string[], raw = false): Promise<any> => {
return Dataset.findOne({ where: { alias }, attributes, raw: raw });
return Dataset.findOne({ where: { alias, status: DatasetStatus.Live }, attributes, raw: raw });
}

findDatasets = async (where?: Record<string, any>, attributes?: string[], order?: any): Promise<any> => {
Expand Down

0 comments on commit a925e35

Please sign in to comment.