diff --git a/src/routes/qumlBulkRoutes.js b/src/routes/qumlBulkRoutes.js index 2beb7eccc6e2e532b8fcbdbd5cb192619f13f766..86261ba16ea1bb64fdf55ac4ce7396e47f2acb4c 100644 --- a/src/routes/qumlBulkRoutes.js +++ b/src/routes/qumlBulkRoutes.js @@ -4,12 +4,12 @@ const qumlRequestMiddleware = require('../validators/qumlBulkUploadValidators'); const BASE_URL = '/question/v1'; module.exports = function (app) { - app.route(BASE_URL + '/bulkupload/') + app.route(BASE_URL + '/bulkupload') .post(requestMiddleware.gzipCompression(), requestMiddleware.createAndValidateRequestBody, requestMiddleware.checkChannelID, qumlRequestMiddleware.qumlBulkUploadValidator(),qumlRequestMiddleware.validate, qumlBulkUpload.bulkUpload); - app.route(BASE_URL + '/bulkUploadStatus') + app.route(BASE_URL + '/bulkupload/status') .post(requestMiddleware.gzipCompression(), requestMiddleware.createAndValidateRequestBody, qumlBulkUpload.qumlSearch); } diff --git a/src/service/qumlBulkService.js b/src/service/qumlBulkService.js index d1acec9066cd647d74e467b7f1713604875b81b4..bab0185624b6b51d55ca015269643e9ee75d9044 100644 --- a/src/service/qumlBulkService.js +++ b/src/service/qumlBulkService.js @@ -68,7 +68,7 @@ const bulkUpload = async (req, res) => { }); logger.info({ message: "Bulk Upload process has started successfully for the process Id", pId}); rspObj.responseCode = responseCode.SUCCESS; - rspObj.result = { processId: pId}; + rspObj.result = { processId: pId, count: qumlData.length}; loggerService.exitLog({responseCode: rspObj.responseCode}, logObject); return res.status(200).send(successResponse(rspObj)) }).catch(err => { @@ -230,6 +230,7 @@ const qumlSearch = (req, res) => { message: programMessages.QUML_BULKSTATUS.INFO, }; loggerService.entryLog("Api to check the status of bulk upload question", logObject); + const errCode = programMessages.EXCEPTION_CODE+'_'+programMessages.QUML_BULKSTATUS.EXCEPTION_CODE fetch(`${envVariables.baseURL}/action/composite/v3/search`, { method: "POST", // or 'PUT' headers: { @@ -239,11 +240,9 @@ const qumlSearch = (req, res) => { }) .then((response) => response.json()) .then(async(resData) => { - console.log(resData); rspObj.responseCode = resData.responseCode || responseCode.SUCCESS; rspObj.result = { ...resData.result } logger.info({ message: "Successfully Fetched the data", rspObj }); - // res.csv(resData.result.Question) loggerService.exitLog( "Successfully got the Questions", rspObj, @@ -251,26 +250,13 @@ const qumlSearch = (req, res) => { return res.status(200).send(successResponse(rspObj)) }) .catch((error) => { - rspObj.errMsg = "Something went wrong while fetching the data"; + console.log('Error while fetching the question :: ', JSON.stringify(error)); + rspObj.errCode = programMessages.QUML_BULKSTATUS.FAILED_CODE; + rspObj.errMsg = programMessages.QUML_BULKSTATUS.FAILED_MESSAGE; rspObj.responseCode = responseCode.SERVER_ERROR; - logger.error( - { - message: "Something went wrong while fetching the data", - errorData: error, - rspObj, - }, - errorCodes.CODE2 - ); - res - .status(400) - .send( - { - message: "Something went wrong while fetching the data", - errorData: error, - rspObj, - }, - errorCodes.CODE2 - ); + loggerError(rspObj,errCode+errorCodes.CODE1); + loggerService.exitLog({responseCode: rspObj.responseCode}, logObject); + return res.status(400).send(errorResponse(rspObj,errCode+errorCodes.CODE1)); }); };