mirror of
https://github.com/Cleanuparr/Cleanuparr.git
synced 2026-10-28 10:48:49 -04:00
fixed completed cycle duration counting until now
This commit is contained in:
1 parent
1e53176486
commit
d41ee0c621
3 files changed
+20
-7
No files matched your search
+2
-2
@@ -77,9 +77,9 @@
|
||||
</div>
|
||||
<div class="instance-card__stat">
|
||||
<span class="instance-card__stat-value">
|
||||
{{ inst.cycleStartedAt ? formatCycleDuration(inst.cycleStartedAt) : '—' }}
|
||||
{{ cycleDuration(inst) }}
|
||||
</span>
|
||||
<app-tooltip text="How long the current search cycle has been running">
|
||||
<app-tooltip text="How long the current search cycle has been running, or took if complete">
|
||||
<span class="instance-card__stat-label">Cycle Duration</span>
|
||||
</app-tooltip>
|
||||
</div>
|
||||
|
||||
+8
-4
@@ -403,15 +403,19 @@ describe('SearchesTabComponent', () => {
|
||||
expect(component.searchReasonSeverity('Whatever')).toBe('default');
|
||||
});
|
||||
|
||||
it('formats the cycle duration down to the largest non-zero unit', () => {
|
||||
it('measures a running cycle until now and a completed cycle until its completion', () => {
|
||||
const { component } = setup();
|
||||
|
||||
vi.useFakeTimers();
|
||||
vi.setSystemTime(new Date('2026-07-31T12:00:00Z'));
|
||||
|
||||
expect(component.formatCycleDuration('2026-07-29T09:00:00Z')).toBe('2d 3h');
|
||||
expect(component.formatCycleDuration('2026-07-31T07:00:00Z')).toBe('5h');
|
||||
expect(component.formatCycleDuration('2026-07-31T11:30:00Z')).toBe('30m');
|
||||
expect(component.cycleDuration(instance({ cycleStartedAt: '2026-07-29T09:00:00Z' }))).toBe('2d 3h');
|
||||
expect(component.cycleDuration(instance({ cycleStartedAt: '2026-07-31T11:30:00Z' }))).toBe('30m');
|
||||
expect(component.cycleDuration(instance({
|
||||
cycleStartedAt: '2026-07-29T09:00:00Z',
|
||||
cycleCompletedAt: '2026-07-29T09:20:00Z',
|
||||
}))).toBe('20m');
|
||||
expect(component.cycleDuration(instance({ cycleStartedAt: null }))).toBe('—');
|
||||
});
|
||||
|
||||
it('toasts the error message when loading search stats fails', () => {
|
||||
|
||||
@@ -316,7 +316,16 @@ export class SearchesTabComponent {
|
||||
readonly searchReasonSeverity = searchReasonSeverity;
|
||||
readonly cycleProgress = cycleProgress;
|
||||
readonly instanceHealthWarning = instanceHealthWarning;
|
||||
readonly formatCycleDuration = formatCycleDuration;
|
||||
|
||||
cycleDuration(inst: InstanceSearchStat): string {
|
||||
const { cycleStartedAt, cycleCompletedAt } = inst;
|
||||
if (!cycleStartedAt) {
|
||||
return '—';
|
||||
}
|
||||
return cycleCompletedAt
|
||||
? formatDurationBetween(cycleStartedAt, cycleCompletedAt)
|
||||
: formatCycleDuration(cycleStartedAt);
|
||||
}
|
||||
|
||||
lastCycleDuration(inst: InstanceSearchStat): string {
|
||||
const { lastCycleStartedAt, lastCycleCompletedAt } = inst;
|
||||
|
||||
Reference in new issue
Block a user