Skip to content

Commit

Permalink
fix(guarantee): removed unused method
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarobernal2412 committed Jan 13, 2025
1 parent a413e2d commit 1edd3f3
Showing 1 changed file with 0 additions and 113 deletions.
113 changes: 0 additions & 113 deletions src/controllers/v6/states/guarantees/guarantees.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,119 +236,6 @@ async function buildGuaranteeQueries(manager, guarantee, lastPeriodFlag, newPeri
return [guarantee.id];
}


// function _guaranteesGET(req, res) {
// const { agreementId } = req.params;
// const from = req.query.from;
// const to = req.query.to;
// const lastPeriod = req.query.lastPeriod ? (req.query.lastPeriod === 'true') : true;
// const newPeriodsFromGuarantees = req.query.newPeriodsFromGuarantees ? (req.query.newPeriodsFromGuarantees === 'true') : true;
// logger.info('New request to GET guarantees - With new periods from guarantees: ' + newPeriodsFromGuarantees);

// let result;
// if (config.streaming) {
// logger.info('### Streaming mode ###');

// res.setHeader('content-type', 'application/json; charset=utf-8');
// result = utils.stream.createReadable();
// result.pipe(JSONStream.stringify()).pipe(res);
// } else {
// logger.info('### NO Streaming mode ###');
// result = [];
// }

// stateManager({
// id: agreementId
// }).then(function (manager) {
// logger.info('Getting state of guarantees...');
// const validationErrors = [];
// if (config.parallelProcess.guarantees) {
// logger.info('### Process mode = PARALLEL ###');

// const guaranteesPromises = [];
// manager.agreement.terms.guarantees.forEach(function (guarantee) {
// const query = new Query(req.query);

// const validation = utils.validators.guaranteeQuery(query, guarantee.id, guarantee);
// if (!validation.valid) {
// validation.guarantee = guarantee.id;
// validationErrors.push(validation);
// } else {
// if (req.query.forceUpdate == 'true') {
// guaranteesPromises.push(manager.get('guarantees', query, true));
// } else {
// guaranteesPromises.push(manager.get('guarantees', query, false));
// }
// }
// });

// if (validationErrors.length === 0) {
// utils.promise.processParallelPromises(manager, guaranteesPromises, result, res, config.streaming);
// } else {
// res.status(400).json(new ErrorModel(400, validationErrors));
// }
// } else {
// logger.info('### Process mode = SEQUENTIAL ###');
// const guaranteesQueries = manager.agreement.terms.guarantees.reduce(function (acc, guarantee) {
// /* Process each guarantee individually, to create queries for every one */
// const guaranteeDefinition = manager.agreement.terms.guarantees.find((e) => {
// return guarantee.id === e.id;
// });
// const requestWindow = guaranteeDefinition.of[0].window; // Get the window of the current guarantee
// let periods;
// /* Create all the queries corresponding for the specified period and the current guarantee */
// let allQueries = [];
// if (from && to) {
// requestWindow.from = from;
// requestWindow.end = to;
// // if (newPeriodsFromGuarantees) {
// if (true) {
// periods = utils.time.getPeriods(manager.agreement, requestWindow);
// } else {
// periods = [{ from: new Date(from).toISOString(), to: new Date(to).toISOString() }];
// }

// // Create query for every period
// allQueries = periods.map(function (period) {
// return gUtils.buildGuaranteeQuery(guarantee.id, period.from, period.to);
// });
// } else {
// if (lastPeriod) {
// const period = utils.time.getLastPeriod(manager.agreement, requestWindow);
// allQueries.push(gUtils.buildGuaranteeQuery(guarantee.id, period.from, period.to));
// } else {
// allQueries.push(guarantee.id);
// }
// }
// /* Validate queries and add to the list */
// const queries = [...acc];
// for (const query of allQueries) {
// const validation = utils.validators.guaranteeQuery(query, guarantee.id);
// if (!validation.valid) {
// validation.guarantee = guarantee.id;
// validationErrors.push(validation);
// } else {
// queries.push(query);
// }
// }
// return queries;
// }, []);
// if (validationErrors.length === 0) {
// if (req.query.forceUpdate == 'true') {
// utils.promise.processSequentialPromises('guarantees', manager, guaranteesQueries, result, res, config.streaming, true);
// } else {
// utils.promise.processSequentialPromises('guarantees', manager, guaranteesQueries, result, res, config.streaming, false);
// }
// } else {
// res.status(400).json(new ErrorModel(400, validationErrors));
// }
// }
// }, function (err) {
// logger.error('(guarantee controller) ' + JSON.stringify(err.message));
// res.status(err.code || 500).json({ message: err.message});
// });
// }

/**
* Get guarantees by ID.
* @param {Object} args {agreement: String, guarantee: String}
Expand Down

0 comments on commit 1edd3f3

Please sign in to comment.