Skip to content

Commit 0c20ab5

Browse files
authored
Merge pull request #83 from parthlambdatest/Dot-3538
[Dot-3538] feat: update poll time to 30 minutes to display summary table
2 parents 9f75a89 + 953147f commit 0c20ab5

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

commands/utils/polling.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ const Table = require('cli-table3');
33
var { constants } = require('./constants');
44

55
var INTERVAL = 2000
6-
const MAX_INTERVAL = 512000
6+
const MAX_EXPONENTIAL_INTERVAL = 512000 // 512 seconds (8.5 minutes)
7+
const FIXED_INTERVAL = 60000 // 1 minute in milliseconds
8+
const MAX_INTERVAL = 1800000; // 30 minutes in milliseconds
9+
var CURRENT_TIME = 0
10+
var FLAG = 0
711

812
async function shortPolling(buildId, retries = 0, options) {
913
await axios.get(new URL('?buildId=' + buildId, constants[options.env].BUILD_STATUS_URL).href, {
@@ -55,19 +59,26 @@ async function shortPolling(buildId, retries = 0, options) {
5559
return;
5660
} else {
5761
if (response.data.screenshots && response.data.screenshots.length > 0) {
58-
// TODO: show Screenshots processed current/total
62+
// TODO: show Screenshots processed current/total
5963
console.log('[smartui] Screenshots compared: ', response.data.screenshots.length)
6064
}
6165
}
6266
}
63-
64-
// Double the INTERVAL, up to the maximum INTERVAL of 512 secs (so ~15 mins in total)
65-
INTERVAL = Math.min(INTERVAL * 2, MAX_INTERVAL);
66-
if (INTERVAL == MAX_INTERVAL) {
67+
68+
CURRENT_TIME = CURRENT_TIME + INTERVAL
69+
if (CURRENT_TIME == MAX_INTERVAL) {
6770
console.log('[smartui] Please check the build status on LambdaTest SmartUI.');
6871
return;
6972
}
7073

74+
// Adjust the interval
75+
if (Math.min(INTERVAL * 2, MAX_EXPONENTIAL_INTERVAL) < MAX_EXPONENTIAL_INTERVAL && FLAG == 0) {
76+
INTERVAL = Math.min(INTERVAL * 2, MAX_EXPONENTIAL_INTERVAL);
77+
} else {
78+
FLAG = 1
79+
INTERVAL = FIXED_INTERVAL; // Switch to fixed interval after reaching 256 seconds
80+
}
81+
7182
setTimeout(function () {
7283
shortPolling(buildId, 0, options)
7384
}, INTERVAL);

0 commit comments

Comments
 (0)