Skip to content

Commit cc2584d

Browse files
committed
feat: Enhance workflow identification by using workflowPath as a fallback in usage report components
1 parent e3fe752 commit cc2584d

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

src/app/components/usage/actions/charts/chart-line-usage-daily/chart-line-usage-daily.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class ChartLineUsageDailyComponent implements OnChanges {
7272
let name = 'Total';
7373
let timeKey = 'total';
7474
if (this.timeType === 'run') {
75-
timeKey = `${line.workflowName || 'Unknown'}${line.date}${index}`;
75+
timeKey = `${line.workflowName || line.workflowPath || 'Unknown'}${line.date}${index}`;
7676
} else if (this.timeType === 'daily') {
7777
timeKey = line.date.toISOString().split('T')[0];
7878
} else if (this.timeType === 'weekly') {
@@ -93,7 +93,7 @@ export class ChartLineUsageDailyComponent implements OnChanges {
9393
} else if (this.chartType === 'repo') {
9494
name = line.repositoryName;
9595
} else if (this.chartType === 'workflow') {
96-
name = line.workflowName || 'Unknown Workflow';
96+
name = line.workflowName || line.workflowPath || 'Unknown Workflow';
9797
} else if (this.chartType === 'total') {
9898
name = 'total';
9999
}

src/app/components/usage/actions/table-workflow-usage/table-workflow-usage.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export class TableWorkflowUsageComponent implements OnChanges, AfterViewInit {
7676
usageItems = this.data.reduce((acc, line) => {
7777
const item = acc.find(a => {
7878
if (this.tableType === 'workflow') {
79-
return a.workflow === (line.workflowName || 'Unknown Workflow')
79+
return a.workflow === (line.workflowName || line.workflowPath || 'Unknown Workflow')
8080
} else if (this.tableType === 'repo') {
8181
return a.repo === line.repositoryName;
8282
} else if (this.tableType === 'sku') {
@@ -129,7 +129,7 @@ export class TableWorkflowUsageComponent implements OnChanges, AfterViewInit {
129129
item.runs++;
130130
} else {
131131
acc.push({
132-
workflow: line.workflowName || 'Unknown Workflow',
132+
workflow: line.workflowName || line.workflowPath || 'Unknown Workflow',
133133
repo: line.repositoryName,
134134
total: line.quantity,
135135
cost: line.quantity * line.pricePerUnit,

src/app/usage-report.service.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,9 @@ export class UsageReportService {
171171
if (!this.repositories.includes(line.repositoryName)) {
172172
this.repositories.push(line.repositoryName);
173173
}
174-
if (line.workflowName && !this.workflows.includes(line.workflowName)) {
175-
this.workflows.push(line.workflowName);
174+
const workflow = line.workflowName || line.workflowPath;
175+
if (workflow && !this.workflows.includes(workflow)) {
176+
this.workflows.push(workflow);
176177
}
177178
if (!this.skus.includes(line.sku)) {
178179
this.skus.push(line.sku);
@@ -201,7 +202,7 @@ export class UsageReportService {
201202
filtered = filtered.filter(line => line.sku === this.filters.sku);
202203
}
203204
if (this.filters.workflow) {
204-
filtered = filtered.filter(line => line.workflowName && line.workflowName === this.filters.workflow);
205+
filtered = filtered.filter(line => (line.workflowName || line.workflowPath) === this.filters.workflow);
205206
}
206207
if (this.filters.startDate && this.filters.endDate) {
207208
filtered = filtered.filter(line => {
@@ -225,8 +226,8 @@ export class UsageReportService {
225226
getWorkflowsFiltered(): Observable<string[]> {
226227
return this.getUsageFilteredByProduct('actions').pipe(
227228
map(lines => lines
228-
.map(line => line.workflowName)
229-
.filter((workflow): workflow is string => workflow !== undefined)
229+
.map(line => line.workflowName || line.workflowPath)
230+
.filter((workflow): workflow is string => workflow !== undefined && workflow !== '')
230231
.filter((workflow, index, self) => self.indexOf(workflow) === index)
231232
),
232233
)

0 commit comments

Comments
 (0)