Commit 8bdc47b5 authored by Nathan Friend's avatar Nathan Friend

Restructure error handling in lead time charts

parent e35b4ce3
...@@ -55,28 +55,25 @@ export default { ...@@ -55,28 +55,25 @@ export default {
async mounted() { async mounted() {
const results = await Promise.allSettled( const results = await Promise.allSettled(
allChartDefinitions.map(async ({ id, requestParams, startDate, endDate }) => { allChartDefinitions.map(async ({ id, requestParams, startDate, endDate }) => {
let apiData;
if (this.projectPath && this.groupPath) { if (this.projectPath && this.groupPath) {
throw new Error('Both projectPath and groupPath were provided'); throw new Error('Both projectPath and groupPath were provided');
} else if (this.projectPath) { }
apiData = (
await DoraApi.getProjectDoraMetrics( if (!this.projectPath && !this.groupPath) {
throw new Error('Either projectPath or groupPath must be provided');
}
const { data: apiData } = this.projectPath
? await DoraApi.getProjectDoraMetrics(
this.projectPath, this.projectPath,
DoraApi.LEAD_TIME_FOR_CHANGES, DoraApi.LEAD_TIME_FOR_CHANGES,
requestParams, requestParams,
) )
).data; : await DoraApi.getGroupDoraMetrics(
} else if (this.groupPath) {
apiData = (
await DoraApi.getGroupDoraMetrics(
this.groupPath, this.groupPath,
DoraApi.LEAD_TIME_FOR_CHANGES, DoraApi.LEAD_TIME_FOR_CHANGES,
requestParams, requestParams,
) );
).data;
} else {
throw new Error('Either projectPath or groupPath must be provided');
}
this.chartData[id] = buildNullSeriesForLeadTimeChart( this.chartData[id] = buildNullSeriesForLeadTimeChart(
apiDataToChartSeries(apiData, startDate, endDate, CHART_TITLE, null), apiDataToChartSeries(apiData, startDate, endDate, CHART_TITLE, null),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment