Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
224 additions
and
409 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/lib/features/feature-toggle/time-to-production/time-to-production.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { calculateAverageTimeToProd } from './time-to-production'; | ||
|
||
describe('calculate average time to production', () => { | ||
test('should calculate average correctly', () => { | ||
const timeToProduction = calculateAverageTimeToProd([ | ||
{ | ||
created: new Date('2022-12-05T09:37:32.483Z'), | ||
enabled: new Date('2023-01-25T09:37:32.504Z'), | ||
}, | ||
{ | ||
created: new Date('2023-01-19T09:37:32.484Z'), | ||
enabled: new Date('2023-01-31T09:37:32.506Z'), | ||
}, | ||
{ | ||
created: new Date('2023-01-19T09:37:32.484Z'), | ||
enabled: new Date('2023-02-02T09:37:32.509Z'), | ||
}, | ||
{ | ||
created: new Date('2023-01-19T09:37:32.486Z'), | ||
enabled: new Date('2023-01-26T09:37:32.508Z'), | ||
}, | ||
]); | ||
|
||
expect(timeToProduction).toBe(21); | ||
}); | ||
}); |
20 changes: 20 additions & 0 deletions
20
src/lib/features/feature-toggle/time-to-production/time-to-production.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { differenceInDays } from 'date-fns'; | ||
import { ICreateEnabledDates } from '../../../types/stores/project-stats-store-type'; | ||
|
||
const calculateTimeToProdForFeatures = ( | ||
items: ICreateEnabledDates[], | ||
): number[] => | ||
items.map((item) => differenceInDays(item.enabled, item.created)); | ||
|
||
export const calculateAverageTimeToProd = ( | ||
items: ICreateEnabledDates[], | ||
): number => { | ||
const timeToProdPerFeature = calculateTimeToProdForFeatures(items); | ||
if (timeToProdPerFeature.length) { | ||
const sum = timeToProdPerFeature.reduce((acc, curr) => acc + curr, 0); | ||
|
||
return Number((sum / Object.keys(items).length).toFixed(1)); | ||
} | ||
|
||
return 0; | ||
}; |
216 changes: 0 additions & 216 deletions
216
src/lib/read-models/time-to-production/time-to-production.test.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.