Skip to content

Commit

Permalink
feat(#385): Refactored validation for if curation exist
Browse files Browse the repository at this point in the history
  • Loading branch information
tholulomo committed May 11, 2023
1 parent a1fcecc commit 633d024
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions resfulservice/src/controllers/curationController.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ const { errorWriter } = require('../utils/logWriter');
const XlsxCurationList = require('../models/xlsxCurationList');

exports.curateXlsxSpreadsheet = async (req, res, next) => {
req.logger.info('curateXlsxSpreadsheet Function Entry:');
const { user } = req;
const { user, logger } = req;

logger.info('curateXlsxSpreadsheet Function Entry:');

if (!req.files?.uploadfile) {
return next(errorWriter(req, 'Material template files not uploaded', 'curateXlsxSpreadsheet', 400));
}
Expand All @@ -20,7 +22,7 @@ exports.curateXlsxSpreadsheet = async (req, res, next) => {
}

try {
const [validList, storedObjects] = await Promise.all([
const [validList, storedCurations] = await Promise.all([
XlsxCurationList.find({}, null, { lean: true }),
XlsxObject.find({ user: user._id }, { object: 1 }, { lean: true })
]);
Expand All @@ -31,7 +33,7 @@ exports.curateXlsxSpreadsheet = async (req, res, next) => {

if (result?.count) return res.status(400).json({ errors: result.errors });

const curatedAlready = storedObjects.find(
const curatedAlready = storedCurations.find(
object => object?.['data origin']?.Title === result?.['data origin']?.Title &&
object?.['data origin']?.['Publication Type'] === result?.['data origin']?.['Publication Type']);

Expand Down

0 comments on commit 633d024

Please sign in to comment.