功能推送阻止其他功能的执行

时间:2019-06-11 10:17:07

标签: javascript jira

我正在将值(80)推送到自定义字段

然后我正在使用setTimeout并执行一些函数(计算),但是在脚本的结尾,我可以看到我的推送值不起作用...

// Call the file functions.js
var functions = require('./functions.js')

/* 
Function getAllIssueForSCII displays all the issues in the form of a JSON and that browses all the keys that are in the SCII project
Function pushInitialization initializes the computer score card to 80 on Jira
*/

functions.getAllIssueForSCII().then(function(json){
    for (let i=0; i<json.issues.length;i++){
        console.log(json.issues[i].key);
        functions.pushInitialization(json.issues[i].key);

        setTimeout(function() {
            functions.calculate(json.issues[i]);
            functions.pushComputerScoreCard(json.issues[i].key);
            functions.generateJSON(json.issues[i].key);
            functions.replaceCharacter();      
        }, 5000)
    } 
});

但是当我这样做时,它可以工作,但是我不喜欢..:

functions.getAllIssueForSCII().then(function(json){
    for (let i=0; i<json.issues.length;i++){
        console.log(json.issues[i].key);
        functions.pushInitialization(json.issues[i].key);
        }
});

/* 
A delay is added so that Jira can correctly recover the value 80.
Thanks to this value, we can do all the calculation  (Function calculate)  
Function pushComputerScoreCard  push the final value into the computer score card.
Function generateJSON generates a JSON.
Function replaceCharacter solve the problem of array inside the JSON 
*/

setTimeout(function() {
    functions.getAllIssueForSCII().then(function(json){
        for (let i=0; i<json.issues.length;i++){
            functions.calculate(json.issues[i]);
            functions.pushComputerScoreCard(json.issues[i].key);
            functions.generateJSON(json.issues[i].key);
            functions.replaceCharacter();
        }       
    });
}, 1000)

/*
A delay is added for recover correctly the file into Azure Blob Storage 
*/

实际结果:

  • 5

预期结果:

  • 85

0 个答案:

没有答案