JSFiddle - React, Tailwind, and code Playground
by pierian_design
JavaScript
let _getStepsFromSheet = function (oSheetInfo) {
let aResult = [];
function Step() {
this.rows = {};
this.sheetInfo = oSheetInfo.sheetInfo;
}
let aSteps = [];
let oStep = new Step();
let oRows = oSheetInfo.rows;
let sliceStart = 0;
let addedRequests = 0;
let maxRequestsOnStep = 3;
//let counter = 0;
let splittedStepReq = 0;
for (let status in oRows) { // tut Каждый статус листа
if (oRows[status].length <= maxRequestsOnStep) { // tut если весь статус меньше лимита, добавляем в новый шаг
oStep.rows[status] = oRows[status]; // tut ЕСЛИ СТАТУС МЕНЬШЕ ЛИМИТА, ДОБАВЛЯЕМ В НОВЫЙ ШАГ
aSteps.push(oStep);
if (oStep.rows[status].length !== maxRequestsOnStep) {
splittedStepReq = splittedStepReq + oStep.rows[status].length;
} else {
splittedStepReq = 0;
}
sliceStart = 0;
} else {
/*
let stepsCount = Math.ceil(oRows[status].length / maxRequestsOnStep);
for (let i = 0; i < stepsCount; i++) {
oStep.rows[status] = oRows[status].slice(sliceStart, sliceStart + maxRequestsOnStep);
sliceStart = sliceStart + maxRequestsOnStep;
aSteps.push(oStep);
oStep = new Step();
*/
if (oStep.rows[status].length !== maxRequestsOnStep) {
splittedStepReq = splittedStepReq + oStep.rows[status].length;
} else {
splittedStepReq = 0;
}
}
}
}
console.log('%c --------------DIFFERENCES 1------------------', 'color: white; background: green;');
console.log(aSteps);
console.log(aResult);
aResult = aResult.concat(aSteps);
return aResult;
}
let aDiffsBySheets = [
{
"rows": {
"unique": [
[1],
[3,4]
],
"different": [
...