Format execution durations with adaptive units
This commit is contained in:
parent
2446762e88
commit
d0ca908b02
|
|
@ -79,12 +79,28 @@ export class TasksExecutor {
|
|||
}
|
||||
|
||||
private formatDuration(startTime: number | null, endTime: number | null): string {
|
||||
if (!startTime || !endTime) return '00:00:00';
|
||||
if (!startTime || !endTime) return '0 sec';
|
||||
const diffMs = Math.max(0, endTime - startTime);
|
||||
const totalSeconds = Math.floor(diffMs / 1000);
|
||||
const hh = String(Math.floor(totalSeconds / 3600)).padStart(2, '0');
|
||||
const mm = String(Math.floor((totalSeconds % 3600) / 60)).padStart(2, '0');
|
||||
const ss = String(totalSeconds % 60).padStart(2, '0');
|
||||
return `${hh}:${mm}:${ss}`;
|
||||
const totalMinutes = Math.floor(totalSeconds / 60);
|
||||
const totalHours = Math.floor(totalMinutes / 60);
|
||||
const totalDays = Math.floor(totalHours / 24);
|
||||
|
||||
if (totalSeconds < 60) {
|
||||
return `${totalSeconds} sec`;
|
||||
}
|
||||
|
||||
if (totalMinutes < 60) {
|
||||
const seconds = totalSeconds % 60;
|
||||
return seconds > 0 ? `${totalMinutes} min ${seconds} sec` : `${totalMinutes} min`;
|
||||
}
|
||||
|
||||
if (totalHours < 24) {
|
||||
const minutes = totalMinutes % 60;
|
||||
return minutes > 0 ? `${totalHours} h ${minutes} min` : `${totalHours} h`;
|
||||
}
|
||||
|
||||
const hours = totalHours % 24;
|
||||
return hours > 0 ? `${totalDays} gg ${hours} h` : `${totalDays} gg`;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
</div>
|
||||
<div class="bg-slate-50 border border-slate-200 rounded-md p-2">
|
||||
<div class="text-xs text-slate-500">Duration</div>
|
||||
<div class="text-sm font-medium text-slate-800">{{ durationMs() != null ? durationMs() + ' ms' : '-' }}</div>
|
||||
<div class="text-sm font-medium text-slate-800">{{ formattedDuration() }}</div>
|
||||
</div>
|
||||
<div class="bg-slate-50 border border-slate-200 rounded-md p-2">
|
||||
<div class="text-xs text-slate-500">Steps</div>
|
||||
|
|
|
|||
|
|
@ -65,10 +65,10 @@ export class TaskExecutionViewerComponent implements OnDestroy {
|
|||
return { blocks, connections };
|
||||
});
|
||||
|
||||
readonly durationMs = computed(() => {
|
||||
readonly formattedDuration = computed(() => {
|
||||
const context = this.execution()?.context;
|
||||
if (!context?.startTime || !context?.endTime) return null;
|
||||
return Math.max(0, context.endTime - context.startTime);
|
||||
if (!context?.startTime || !context?.endTime) return '-';
|
||||
return this.formatDuration(context.startTime, context.endTime);
|
||||
});
|
||||
|
||||
readonly inputsReadOnly = computed(() => {
|
||||
|
|
@ -239,6 +239,31 @@ export class TaskExecutionViewerComponent implements OnDestroy {
|
|||
this.textInputDebounceTimers.delete(timerKey);
|
||||
}
|
||||
|
||||
private formatDuration(startTime: number, endTime: number): string {
|
||||
const diffMs = Math.max(0, endTime - startTime);
|
||||
const totalSeconds = Math.floor(diffMs / 1000);
|
||||
const totalMinutes = Math.floor(totalSeconds / 60);
|
||||
const totalHours = Math.floor(totalMinutes / 60);
|
||||
const totalDays = Math.floor(totalHours / 24);
|
||||
|
||||
if (totalSeconds < 60) {
|
||||
return `${totalSeconds} sec`;
|
||||
}
|
||||
|
||||
if (totalMinutes < 60) {
|
||||
const seconds = totalSeconds % 60;
|
||||
return seconds > 0 ? `${totalMinutes} min ${seconds} sec` : `${totalMinutes} min`;
|
||||
}
|
||||
|
||||
if (totalHours < 24) {
|
||||
const minutes = totalMinutes % 60;
|
||||
return minutes > 0 ? `${totalHours} h ${minutes} min` : `${totalHours} h`;
|
||||
}
|
||||
|
||||
const hours = totalHours % 24;
|
||||
return hours > 0 ? `${totalDays} gg ${hours} h` : `${totalDays} gg`;
|
||||
}
|
||||
|
||||
private inferConnections(steps: TaskExecutionStep[]) {
|
||||
const connections: FlowData['connections'] = [];
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue