Bug 1581739 - Fix when NaN duration is displayed (#5512)

This commit is contained in:
Cameron Dawson 2019-10-14 17:51:01 -07:00 коммит произвёл GitHub
Родитель e513f86661
Коммит 7fd8bd2e00
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 9 добавлений и 5 удалений

Просмотреть файл

@ -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;
};