@@ -1615,6 +1615,51 @@ describe("DORA Metrics", () => {
16151615 // Should only see workspace 1's data: 1 deployment, 1 incident = 100%
16161616 expect ( result . currentAmount ) . toBeCloseTo ( 100 , 1 ) ;
16171617 } ) ;
1618+
1619+ it ( "excludes archived incidents from the failure rate" , async ( ) => {
1620+ const ctx = await createTestContextWithGitProfile ( ) ;
1621+ const gitProfile = await seedGitProfile ( ctx ) ;
1622+ const repository = await seedRepository ( ctx ) ;
1623+ const application = await seedApplication ( ctx , repository . repositoryId ) ;
1624+ const environment = await seedEnvironment ( ctx , { isProduction : true } ) ;
1625+
1626+ const pr = await seedPullRequest (
1627+ ctx ,
1628+ repository . repositoryId ,
1629+ gitProfile . gitProfileId ,
1630+ { createdAt : new Date ( "2024-01-15T10:00:00Z" ) }
1631+ ) ;
1632+ const deployment = await seedDeployment (
1633+ ctx ,
1634+ application . applicationId ,
1635+ environment . environmentId ,
1636+ {
1637+ deployedAt : new Date ( "2024-01-15T14:00:00Z" ) ,
1638+ authorId : gitProfile . gitProfileId ,
1639+ }
1640+ ) ;
1641+ await seedDeploymentPullRequest (
1642+ ctx ,
1643+ deployment . deploymentId ,
1644+ pr . pullRequestId
1645+ ) ;
1646+ const archived = await seedIncident ( ctx , deployment . deploymentId , {
1647+ detectedAt : new Date ( "2024-01-15T15:00:00Z" ) ,
1648+ resolvedAt : new Date ( "2024-01-15T16:00:00Z" ) ,
1649+ } ) ;
1650+ await getPrisma ( ctx . workspaceId ) . incident . update ( {
1651+ where : { id : archived . incidentId } ,
1652+ data : { archivedAt : new Date ( "2024-01-16T00:00:00Z" ) } ,
1653+ } ) ;
1654+
1655+ const result = await getChangeFailureRateMetric ( {
1656+ workspaceId : ctx . workspaceId ,
1657+ dateRange : { from : "2024-01-15T00:00:00Z" , to : "2024-01-16T00:00:00Z" } ,
1658+ period : Period . DAILY ,
1659+ } ) ;
1660+
1661+ expect ( result . currentAmount ) . toBe ( 0 ) ;
1662+ } ) ;
16181663 } ) ;
16191664
16201665 describe ( "Mean Time To Recover (MTTR)" , ( ) => {
@@ -2325,6 +2370,51 @@ describe("DORA Metrics", () => {
23252370 // Should only see workspace 1's data: 2 hours = 7,200,000 ms
23262371 expect ( result . currentAmount ) . toBe ( BigInt ( 7200000 ) ) ;
23272372 } ) ;
2373+
2374+ it ( "excludes incidents whose cause deployment is archived" , async ( ) => {
2375+ const ctx = await createTestContextWithGitProfile ( ) ;
2376+ const gitProfile = await seedGitProfile ( ctx ) ;
2377+ const repository = await seedRepository ( ctx ) ;
2378+ const application = await seedApplication ( ctx , repository . repositoryId ) ;
2379+ const environment = await seedEnvironment ( ctx , { isProduction : true } ) ;
2380+
2381+ const pr = await seedPullRequest (
2382+ ctx ,
2383+ repository . repositoryId ,
2384+ gitProfile . gitProfileId ,
2385+ { createdAt : new Date ( "2024-01-15T10:00:00Z" ) }
2386+ ) ;
2387+ const deployment = await seedDeployment (
2388+ ctx ,
2389+ application . applicationId ,
2390+ environment . environmentId ,
2391+ {
2392+ deployedAt : new Date ( "2024-01-15T10:00:00Z" ) ,
2393+ authorId : gitProfile . gitProfileId ,
2394+ }
2395+ ) ;
2396+ await seedDeploymentPullRequest (
2397+ ctx ,
2398+ deployment . deploymentId ,
2399+ pr . pullRequestId
2400+ ) ;
2401+ await seedIncident ( ctx , deployment . deploymentId , {
2402+ detectedAt : new Date ( "2024-01-15T11:00:00Z" ) ,
2403+ resolvedAt : new Date ( "2024-01-15T13:00:00Z" ) ,
2404+ } ) ;
2405+ await getPrisma ( ctx . workspaceId ) . deployment . update ( {
2406+ where : { id : deployment . deploymentId } ,
2407+ data : { archivedAt : new Date ( "2024-01-16T00:00:00Z" ) } ,
2408+ } ) ;
2409+
2410+ const result = await getMeanTimeToRecoverMetric ( {
2411+ workspaceId : ctx . workspaceId ,
2412+ dateRange : { from : "2024-01-15T00:00:00Z" , to : "2024-01-16T00:00:00Z" } ,
2413+ period : Period . DAILY ,
2414+ } ) ;
2415+
2416+ expect ( result . currentAmount ) . toBe ( BigInt ( 0 ) ) ;
2417+ } ) ;
23282418 } ) ;
23292419
23302420 describe ( "Deployment Frequency" , ( ) => {
0 commit comments