mirror of
https://github.com/Unleash/unleash.git
synced 2025-10-13 11:17:26 +02:00
Currently the median time to production stat is showing the aggregated median across all dates. This pr changes the calculation to only use the last week summary like the rest of the stat widgets. <img width="1665" alt="Screenshot 2024-04-03 at 11 25 31" src="https://github.com/Unleash/unleash/assets/104830839/c6869b48-99bd-4f5b-a25e-7e0e3a2dc9ef"> --------- Signed-off-by: andreas-unleash <andreas@getunleash.ai>
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
import { useMemo } from 'react';
|
|
import type { InstanceInsightsSchema } from 'openapi';
|
|
import { useFilteredTrends } from './useFilteredTrends';
|
|
import { useGroupedProjectTrends } from './useGroupedProjectTrends';
|
|
import { useFilteredFlagsSummary } from './useFilteredFlagsSummary';
|
|
|
|
export const useInsightsData = (
|
|
executiveDashboardData: InstanceInsightsSchema,
|
|
projects: string[],
|
|
) => {
|
|
const projectsData = useFilteredTrends(
|
|
executiveDashboardData.projectFlagTrends,
|
|
projects,
|
|
);
|
|
|
|
const groupedProjectsData = useGroupedProjectTrends(projectsData);
|
|
|
|
const metricsData = useFilteredTrends(
|
|
executiveDashboardData.metricsSummaryTrends,
|
|
projects,
|
|
);
|
|
const groupedMetricsData = useGroupedProjectTrends(metricsData);
|
|
|
|
const summary = useFilteredFlagsSummary(
|
|
projectsData,
|
|
executiveDashboardData.users,
|
|
);
|
|
|
|
return useMemo(
|
|
() => ({
|
|
...executiveDashboardData,
|
|
projectsData,
|
|
groupedProjectsData,
|
|
metricsData,
|
|
groupedMetricsData,
|
|
users: executiveDashboardData.users,
|
|
environmentTypeTrends: executiveDashboardData.environmentTypeTrends,
|
|
summary,
|
|
}),
|
|
[
|
|
executiveDashboardData,
|
|
projects,
|
|
projectsData,
|
|
groupedProjectsData,
|
|
metricsData,
|
|
groupedMetricsData,
|
|
summary,
|
|
],
|
|
);
|
|
};
|