-
-
Notifications
You must be signed in to change notification settings - Fork 656
/
useProjectInsights.ts
70 lines (66 loc) · 1.9 KB
/
useProjectInsights.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { fetcher, useApiGetter } from '../useApiGetter/useApiGetter';
import type { ProjectInsightsSchema } from '../../../../openapi';
import { formatApiPath } from 'utils/formatPath';
const path = (projectId: string) => `api/admin/projects/${projectId}/insights`;
const placeholderData: ProjectInsightsSchema = {
stats: {
avgTimeToProdCurrentWindow: 0,
createdCurrentWindow: 0,
createdPastWindow: 0,
archivedCurrentWindow: 0,
archivedPastWindow: 0,
projectActivityCurrentWindow: 0,
projectActivityPastWindow: 0,
projectMembersAddedCurrentWindow: 0,
},
featureTypeCounts: [
{
type: 'experiment',
count: 0,
},
{
type: 'permission',
count: 0,
},
{
type: 'release',
count: 0,
},
],
leadTime: {
projectAverage: 0,
features: [
{ name: 'feature1', timeToProduction: 0 },
{ name: 'feature2', timeToProduction: 0 },
{ name: 'feature3', timeToProduction: 0 },
{ name: 'feature4', timeToProduction: 0 },
{ name: 'feature5', timeToProduction: 2 },
],
},
health: {
rating: 0,
activeCount: 0,
potentiallyStaleCount: 0,
staleCount: 0,
},
members: {
currentMembers: 0,
change: 0,
},
changeRequests: {
total: 0,
applied: 0,
approved: 0,
rejected: 0,
reviewRequired: 0,
scheduled: 0,
},
};
export const useProjectInsights = (projectId: string) => {
const projectPath = formatApiPath(path(projectId));
const { data, refetch, loading, error } =
useApiGetter<ProjectInsightsSchema>(projectPath, () =>
fetcher(projectPath, 'Outdated SDKs'),
);
return { data: data || placeholderData, refetch, loading, error };
};