From 3a50df5ee3ac4f655424c8f01274ade633936940 Mon Sep 17 00:00:00 2001 From: Ryan Vazquez Date: Fri, 4 Dec 2020 15:31:07 -0500 Subject: [PATCH 1/3] convert duration + billing date to intervals --- plugins/cost-insights/src/api/CostInsightsApi.ts | 11 ++--------- .../components/ProductInsights/ProductInsights.tsx | 8 +++----- plugins/cost-insights/src/index.ts | 1 - 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/plugins/cost-insights/src/api/CostInsightsApi.ts b/plugins/cost-insights/src/api/CostInsightsApi.ts index 9baad5ffab..28e72bccc6 100644 --- a/plugins/cost-insights/src/api/CostInsightsApi.ts +++ b/plugins/cost-insights/src/api/CostInsightsApi.ts @@ -18,7 +18,6 @@ import { createApiRef } from '@backstage/core'; import { Alert, Cost, - Duration, Entity, Group, Project, @@ -38,15 +37,9 @@ export type ProductInsightsOptions = { group: string; /** - * A time duration, such as P1M. See the Duration type for a detailed explanation - * of how the durations are interpreted in Cost Insights. + * An ISO 8601 repeating interval string, such as R2/P3M/2020-09-01 */ - duration: Duration; - - /** - * The most current date for which billing data is complete, in YYYY-MM-DD format. - */ - lastCompleteBillingDate: string; + intervals: string; /** * (optional) The project id from getGroupProjects or query parameters diff --git a/plugins/cost-insights/src/components/ProductInsights/ProductInsights.tsx b/plugins/cost-insights/src/components/ProductInsights/ProductInsights.tsx index 52abe3fd8b..0ef35bf04c 100644 --- a/plugins/cost-insights/src/components/ProductInsights/ProductInsights.tsx +++ b/plugins/cost-insights/src/components/ProductInsights/ProductInsights.tsx @@ -21,7 +21,7 @@ import { useApi } from '@backstage/core'; import { costInsightsApiRef } from '../../api'; import { ProductInsightsCardList } from '../ProductInsightsCard/ProductInsightsCardList'; import { Duration, Entity, Maybe, Product } from '../../types'; -import { DEFAULT_DURATION } from '../../utils/duration'; +import { intervalsOf, DEFAULT_DURATION } from '../../utils/duration'; import { DefaultLoadingAction, initialStatesOf, @@ -75,8 +75,7 @@ export const ProductInsights = ({ group: group, project: project, product: product.kind, - duration: duration, - lastCompleteBillingDate: lastCompleteBillingDate, + intervals: intervalsOf(duration, lastCompleteBillingDate), }); }, [client, group, project, lastCompleteBillingDate], @@ -97,8 +96,7 @@ export const ProductInsights = ({ group: group, project: project, product: product.kind, - duration: DEFAULT_DURATION, - lastCompleteBillingDate: lastCompleteBillingDate, + intervals: intervalsOf(DEFAULT_DURATION, lastCompleteBillingDate), }), ), ).then(settledResponseOf); diff --git a/plugins/cost-insights/src/index.ts b/plugins/cost-insights/src/index.ts index 28bdb1a8b3..7cd0456ad1 100644 --- a/plugins/cost-insights/src/index.ts +++ b/plugins/cost-insights/src/index.ts @@ -21,5 +21,4 @@ export * from './components'; export { useCurrency } from './hooks'; export * from './types'; export * from './utils/tests'; -export * from './utils/duration'; export * from './utils/alerts'; From cd26fb65778693662a9298ba0047d29fbfe41fe9 Mon Sep 17 00:00:00 2001 From: Ryan Vazquez Date: Fri, 4 Dec 2020 15:31:38 -0500 Subject: [PATCH 2/3] supress recharts react warnings in test --- .../ProjectGrowthAlertCard/ProjectGrowthAlertCard.test.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/cost-insights/src/components/ProjectGrowthAlertCard/ProjectGrowthAlertCard.test.tsx b/plugins/cost-insights/src/components/ProjectGrowthAlertCard/ProjectGrowthAlertCard.test.tsx index db3f2f9bf6..0e24f042bc 100644 --- a/plugins/cost-insights/src/components/ProjectGrowthAlertCard/ProjectGrowthAlertCard.test.tsx +++ b/plugins/cost-insights/src/components/ProjectGrowthAlertCard/ProjectGrowthAlertCard.test.tsx @@ -27,6 +27,9 @@ import { AlertCost } from '../../types'; import { defaultCurrencies } from '../../utils/currency'; import { findAlways } from '../../utils/assert'; +// suppress recharts componentDidUpdate deprecation warnings +jest.spyOn(console, 'warn').mockImplementation(() => {}); + const engineers = findAlways(defaultCurrencies, c => c.kind === null); const MockProject = 'test-project-1'; From d6e8099ed58b2558b707edda62bb37b2d0f03e10 Mon Sep 17 00:00:00 2001 From: Ryan Vazquez Date: Fri, 4 Dec 2020 15:35:59 -0500 Subject: [PATCH 3/3] changeset --- .changeset/cost-insights-wet-walls-jog.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/cost-insights-wet-walls-jog.md diff --git a/.changeset/cost-insights-wet-walls-jog.md b/.changeset/cost-insights-wet-walls-jog.md new file mode 100644 index 0000000000..8de3037f19 --- /dev/null +++ b/.changeset/cost-insights-wet-walls-jog.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-cost-insights': minor +--- + +convert duration + last completed billing date to intervals