synapse-react-client
Version:
[](https://travis-ci.com/Sage-Bionetworks/Synapse-React-Client) [](https://badge.fury.io/js/synaps
39 lines • 1.83 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.convertEvaluationRoundToInput = void 0;
var tslib_1 = require("tslib");
var shortid_1 = (0, tslib_1.__importDefault)(require("shortid"));
var convertEvaluationRoundToInput = function (evaluationRound, reactListKey) {
return {
reactListKey: reactListKey !== null && reactListKey !== void 0 ? reactListKey : shortid_1.default.generate(),
evaluationId: evaluationRound.evaluationId,
id: evaluationRound.id,
etag: evaluationRound.etag,
roundStart: evaluationRound.roundStart,
roundEnd: evaluationRound.roundEnd,
totalSubmissionLimit: extractTotalLimit(evaluationRound.limits),
otherLimits: convertRoundLimitsToInput(evaluationRound.limits),
};
};
exports.convertEvaluationRoundToInput = convertEvaluationRoundToInput;
var extractTotalLimit = function (limits) {
return (limits || [])
.filter(function (evaluationLimit) { return evaluationLimit.limitType === 'TOTAL'; })
.reduce(function (ignorePrevValue, evaluationLimit) {
//after filtering there should exist at most one evaluationLimit
return evaluationLimit.maximumSubmissions.toString();
}, '');
};
var convertRoundLimitsToInput = function (evaluationRoundLimits) {
return (evaluationRoundLimits || [])
.filter(function (evaluationLimit) { return evaluationLimit.limitType !== 'TOTAL'; })
.reduce(function (limitInputList, evaluationLimit) {
limitInputList.push({
type: evaluationLimit.limitType,
maxSubmissionString: evaluationLimit.maximumSubmissions.toString(),
});
//after filtering there should exist at most one evaluationLimit
return limitInputList;
}, []);
};
//# sourceMappingURL=models.js.map