зеркало из https://github.com/mozilla/treeherder.git
Bug 1581739 - Fix when NaN duration is displayed (#5512)
This commit is contained in:
Родитель
e513f86661
Коммит
7fd8bd2e00
|
@ -672,7 +672,8 @@ class Job(models.Model):
|
|||
def get_duration(submit_time, start_time, end_time):
|
||||
endtime = end_time if to_timestamp(end_time) else datetime.datetime.now()
|
||||
starttime = start_time if to_timestamp(start_time) else submit_time
|
||||
return round((endtime - starttime).total_seconds() / 60)
|
||||
seconds = max((endtime - starttime).total_seconds(), 60)
|
||||
return max(round(seconds / 60), 1)
|
||||
|
||||
|
||||
class TaskclusterMetadata(models.Model):
|
||||
|
|
|
@ -176,7 +176,6 @@ export const addAggregateFields = function addAggregateFields(job) {
|
|||
platform,
|
||||
platform_option,
|
||||
signature,
|
||||
duration,
|
||||
submit_timestamp,
|
||||
start_timestamp,
|
||||
end_timestamp,
|
||||
|
@ -199,16 +198,20 @@ export const addAggregateFields = function addAggregateFields(job) {
|
|||
.join(' ');
|
||||
job.searchStr = `${job.title} ${signature}`;
|
||||
|
||||
if (!duration) {
|
||||
if (!('duration' in job)) {
|
||||
// If start time is 0, then duration should be from requesttime to now
|
||||
// If we have starttime and no endtime, then duration should be starttime to now
|
||||
// If we have both starttime and endtime, then duration will be between those two
|
||||
const endtime = end_timestamp || Date.now() / 1000;
|
||||
const starttime = start_timestamp || submit_timestamp;
|
||||
job.duration = Math.round((endtime - starttime) / 60, 0);
|
||||
const diff = Math.max(endtime - starttime, 60);
|
||||
|
||||
job.duration = Math.round(diff / 60, 0);
|
||||
}
|
||||
|
||||
job.hoverText = `${job_type_name} - ${job.resultStatus} - ${job.duration} mins`;
|
||||
job.hoverText = `${job_type_name} - ${job.resultStatus} - ${
|
||||
job.duration
|
||||
} min${job.duration > 1 ? 's' : ''}`;
|
||||
return job;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче