Skip to content

Commit bc2c0fb

Browse files
marksvcNateowami
authored andcommitted
Draft jobs table: Show caution for older data
1 parent b4cc938 commit bc2c0fb

4 files changed

Lines changed: 50 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ This repository contains three interconnected applications:
113113

114114
- Pay attention to available types and type guards in src/SIL.XForge.Scripture/ClientApp/src/type-utils.ts.
115115

116+
# Tests
117+
118+
- If a unit test is more than 20 lines long, then place a line with "// SUT" before the line that causes the code being tested to be exercised.
119+
116120
# Running commands
117121

118122
- If you run frontend tests, run them in the `src/SIL.XForge.Scripture/ClientApp` directory with a command such as `npm run test:headless -- --watch=false --include '**/text.component.spec.ts' --include '**/settings.component.spec.ts'`

src/SIL.XForge.Scripture/ClientApp/src/app/serval-administration/draft-jobs.component.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@
4848
</div>
4949
</div>
5050

51+
@if (shouldShowDurationComparisonCaution) {
52+
<app-notice icon="calendar_month" type="warning">
53+
Be careful about comparing Serval build outcomes and durations before 2025-12-18 with those after, because of
54+
changes to the event grouping system.
55+
</app-notice>
56+
}
57+
5158
@if (!isLoading) {
5259
@if (currentProjectFilter) {
5360
<app-notice icon="filter_alt" mode="fill-dark">

src/SIL.XForge.Scripture/ClientApp/src/app/serval-administration/draft-jobs.component.spec.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,35 @@ describe('DraftJobsComponent', () => {
648648
}));
649649
});
650650

651+
describe('shouldShowDurationComparisonCaution', () => {
652+
it('should return false if no date range is set', fakeAsync(() => {
653+
const env = new TestEnvironment({ hasEvents: false });
654+
env.wait();
655+
env.component['currentDateRange'] = undefined;
656+
657+
// SUT
658+
expect(env.component.shouldShowDurationComparisonCaution).toBeFalse();
659+
}));
660+
661+
it('should return true when the date range starts before the cutoff', fakeAsync(() => {
662+
const env = new TestEnvironment({ hasEvents: false });
663+
env.wait();
664+
env.setDateRange(new Date('2025-12-01'), new Date('2026-01-20'));
665+
666+
// SUT
667+
expect(env.component.shouldShowDurationComparisonCaution).toBeTrue();
668+
}));
669+
670+
it('should return false when the date range starts after the cutoff', fakeAsync(() => {
671+
const env = new TestEnvironment({ hasEvents: false });
672+
env.wait();
673+
env.setDateRange(new Date('2026-01-20'), new Date('2026-02-20'));
674+
675+
// SUT
676+
expect(env.component.shouldShowDurationComparisonCaution).toBeFalse();
677+
}));
678+
});
679+
651680
describe('formatDurationInHours', () => {
652681
it('should format duration in decimal hours', fakeAsync(() => {
653682
const env = new TestEnvironment({ hasEvents: false });

src/SIL.XForge.Scripture/ClientApp/src/app/serval-administration/draft-jobs.component.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ const DRAFTING_EVENTS = [
136136
]
137137
})
138138
export class DraftJobsComponent extends DataLoadingComponent implements OnInit {
139+
/** Time when draftGenerationRequestId began to be used, which was in SFv5.46.1 shortly before
140+
* 2025-12-18T17:48:57Z. */
141+
private static readonly requestIdIntroductionDate: Date = new Date('2025-12-18T17:48:57Z');
142+
139143
columnsToDisplay: string[] = [
140144
'status',
141145
'projectId',
@@ -210,6 +214,12 @@ export class DraftJobsComponent extends DataLoadingComponent implements OnInit {
210214
return this.formatDurationInHours(this.maxDuration);
211215
}
212216

217+
/** Whether to show a caution notice about comparing older durations. */
218+
get shouldShowDurationComparisonCaution(): boolean {
219+
if (this.currentDateRange == null) return false;
220+
return this.currentDateRange.start < DraftJobsComponent.requestIdIntroductionDate;
221+
}
222+
213223
ngOnInit(): void {
214224
if (
215225
!this.columnsToDisplay.includes('buildDetails') &&

0 commit comments

Comments
 (0)