Add last test launch time in the new /api/runs route

This commit is contained in:
Gaël Métais
2021-03-10 00:54:50 +00:00
parent 36fc0f0e10
commit dc5bd2e71e
2 changed files with 12 additions and 2 deletions
+8 -1
View File
@@ -6,7 +6,7 @@ function RunsQueue() {
'use strict';
var queue = [];
var lastTestTimestamp = 0;
this.push = function(runId) {
var deferred = Q.defer();
@@ -21,6 +21,7 @@ function RunsQueue() {
runId: runId
});
lastTestTimestamp = Date.now();
deferred.resolve();
} else {
@@ -31,6 +32,7 @@ function RunsQueue() {
deferred.notify(position);
},
itIsTimeCallback: function() {
lastTestTimestamp = Date.now();
deferred.resolve();
}
});
@@ -78,6 +80,11 @@ function RunsQueue() {
this.length = function() {
return queue.length;
};
// Returns the number of seconds since the last test was launched
this.timeSinceLastTestStarted = function() {
return Math.round((Date.now() - lastTestTimestamp) / 1000);
};
}
module.exports = RunsQueue;