convert duration + billing date to intervals

This commit is contained in:
Ryan Vazquez
2020-12-04 15:31:07 -05:00
parent b6aa734b23
commit 3a50df5ee3
3 changed files with 5 additions and 15 deletions
@@ -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
@@ -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);
-1
View File
@@ -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';