Merge pull request #3580 from backstage/ryanv/product-insights-intervals
Ryanv/product insights intervals
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-cost-insights': minor
|
||||
---
|
||||
|
||||
convert duration + last completed billing date to intervals
|
||||
@@ -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 P3M. 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
|
||||
|
||||
@@ -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);
|
||||
|
||||
+3
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user