diff --git a/frontend/src/component/application/ApplicationChart.tsx b/frontend/src/component/application/ApplicationChart.tsx index 9d3a26a7cb..367458b070 100644 --- a/frontend/src/component/application/ApplicationChart.tsx +++ b/frontend/src/component/application/ApplicationChart.tsx @@ -5,7 +5,7 @@ import { FC, useLayoutEffect, useRef, useState } from 'react'; import { ApplicationOverviewEnvironmentSchema, ApplicationOverviewSchema, -} from '../../openapi'; +} from 'openapi'; import { useRequiredPathParam } from 'hooks/useRequiredPathParam'; import { HelpIcon } from '../common/HelpIcon/HelpIcon'; import { CloudCircle, Flag, WarningAmberRounded } from '@mui/icons-material'; diff --git a/frontend/src/component/executiveDashboard/MetricsSummaryChart/MetricsChartTooltip/MetricsChartTooltip.tsx b/frontend/src/component/executiveDashboard/MetricsSummaryChart/MetricsChartTooltip/MetricsChartTooltip.tsx index 828a532fbc..862c745e45 100644 --- a/frontend/src/component/executiveDashboard/MetricsSummaryChart/MetricsChartTooltip/MetricsChartTooltip.tsx +++ b/frontend/src/component/executiveDashboard/MetricsSummaryChart/MetricsChartTooltip/MetricsChartTooltip.tsx @@ -109,7 +109,7 @@ export const MetricsSummaryTooltip: VFC<{ tooltip: TooltipState | null }> = ({ /> = ({ isLocalTooltip TooltipComponent={MetricsSummaryTooltip} overrideOptions={{ - parsing: { yAxisKey: 'total', xAxisKey: 'weekId' }, + parsing: { yAxisKey: 'totalRequests', xAxisKey: 'week' }, }} /> ); diff --git a/frontend/src/component/executiveDashboard/useMetricsSummary.ts b/frontend/src/component/executiveDashboard/useMetricsSummary.ts index aa91ab77b5..706279fc0a 100644 --- a/frontend/src/component/executiveDashboard/useMetricsSummary.ts +++ b/frontend/src/component/executiveDashboard/useMetricsSummary.ts @@ -1,72 +1,32 @@ import { useMemo } from 'react'; import { useTheme } from '@mui/material'; -import { ExecutiveSummarySchema } from '../../openapi'; -import { parseISO, getISOWeek, format } from 'date-fns'; +import { + ExecutiveSummarySchema, + ExecutiveSummarySchemaMetricsSummaryTrendsItem, +} from 'openapi'; import { getProjectColor } from './executive-dashboard-utils'; type MetricsSummaryTrends = ExecutiveSummarySchema['metricsSummaryTrends']; -interface GroupedData { - [key: string]: { - [week: string]: { - total: number; - totalYes: number; - totalNo: number; - totalApps: number; - totalEnvironments: number; - totalFlags: number; - }; - }; -} +type GroupedDataByProject = Record< + string, + ExecutiveSummarySchemaMetricsSummaryTrendsItem[] +>; -function groupAndSumData(data: MetricsSummaryTrends): any { - const groupedData: GroupedData = {}; +function groupDataByProject( + data: ExecutiveSummarySchemaMetricsSummaryTrendsItem[], +): GroupedDataByProject { + const groupedData: GroupedDataByProject = {}; data.forEach((item) => { - const weekNumber = getISOWeek(parseISO(item.date)); - const year = format(parseISO(item.date), 'yyyy'); - const weekId = `${year}-${weekNumber.toString().padStart(2, '0')}`; - const project = item.project; - + const { project } = item; if (!groupedData[project]) { - groupedData[project] = {}; + groupedData[project] = []; } - - if (!groupedData[project][weekId]) { - groupedData[project][weekId] = { - total: 0, - totalYes: 0, - totalNo: 0, - totalApps: 0, - totalEnvironments: 0, - totalFlags: 0, - }; - } - - groupedData[project][weekId].total += item.totalYes + item.totalNo; - groupedData[project][weekId].totalYes += item.totalYes; - groupedData[project][weekId].totalNo += item.totalNo; - groupedData[project][weekId].totalApps += item.totalApps; - groupedData[project][weekId].totalEnvironments += - item.totalEnvironments; - groupedData[project][weekId].totalFlags += item.totalFlags; + groupedData[project].push(item); }); - return Object.entries(groupedData).map(([project, weeks]) => { - const color = getProjectColor(project); - return { - label: project, - borderColor: color, - backgroundColor: color, - fill: false, - data: Object.entries(weeks) - .sort(([weekA], [weekB]) => weekA.localeCompare(weekB)) - .map(([weekId, values]) => ({ - weekId, - ...values, - })), - }; - }); + return groupedData; } export const useMetricsSummary = ( @@ -75,7 +35,20 @@ export const useMetricsSummary = ( const theme = useTheme(); const data = useMemo(() => { - return { datasets: groupAndSumData(metricsSummaryTrends) }; + const groupedMetrics = groupDataByProject(metricsSummaryTrends); + const datasets = Object.entries(groupedMetrics).map( + ([project, trends]) => { + const color = getProjectColor(project); + return { + label: project, + data: trends, + borderColor: color, + backgroundColor: color, + fill: false, + }; + }, + ); + return { datasets }; }, [theme, metricsSummaryTrends]); return data; diff --git a/frontend/src/openapi/models/applicationOverviewIssuesSchemaType.ts b/frontend/src/openapi/models/applicationOverviewIssuesSchemaType.ts new file mode 100644 index 0000000000..60dd7739d7 --- /dev/null +++ b/frontend/src/openapi/models/applicationOverviewIssuesSchemaType.ts @@ -0,0 +1,17 @@ +/** + * Generated by Orval + * Do not edit manually. + * See `gen:api` script in package.json + */ + +/** + * The name of this action. + */ +export type ApplicationOverviewIssuesSchemaType = + (typeof ApplicationOverviewIssuesSchemaType)[keyof typeof ApplicationOverviewIssuesSchemaType]; + +// eslint-disable-next-line @typescript-eslint/no-redeclare +export const ApplicationOverviewIssuesSchemaType = { + missingFeatures: 'missingFeatures', + missingStrategies: 'missingStrategies', +} as const; diff --git a/frontend/src/openapi/models/executiveSummarySchemaMetricsSummaryTrendsItem.ts b/frontend/src/openapi/models/executiveSummarySchemaMetricsSummaryTrendsItem.ts index c9b2b679d7..c776164339 100644 --- a/frontend/src/openapi/models/executiveSummarySchemaMetricsSummaryTrendsItem.ts +++ b/frontend/src/openapi/models/executiveSummarySchemaMetricsSummaryTrendsItem.ts @@ -5,8 +5,6 @@ */ export type ExecutiveSummarySchemaMetricsSummaryTrendsItem = { - /** Date the impressions summary were calculated */ - date: string; /** Project id of the project the impressions summary belong to */ project: string; /** Total number of applications the impression data belong to */ @@ -17,6 +15,10 @@ export type ExecutiveSummarySchemaMetricsSummaryTrendsItem = { totalFlags: number; /** Total number of times all project flags were not exposed across all environments */ totalNo: number; + /** Total number of times all project flags were requested */ + totalRequests: number; /** Total number of times all project flags were exposed across all environments */ totalYes: number; + /** Year and week in a given year for which the metrics summary was calculated */ + week: string; }; diff --git a/frontend/src/openapi/models/index.ts b/frontend/src/openapi/models/index.ts index 70d33954a3..2fea49a0a6 100644 --- a/frontend/src/openapi/models/index.ts +++ b/frontend/src/openapi/models/index.ts @@ -575,7 +575,6 @@ export * from './getAllToggles403'; export * from './getApiTokensByName401'; export * from './getApiTokensByName403'; export * from './getApplication404'; -export * from './getApplicationEnvironmentInstances404'; export * from './getApplicationOverview404'; export * from './getApplicationsParams'; export * from './getArchivedFeatures401';