-
Notifications
You must be signed in to change notification settings - Fork 45
feat: add repair attempt graph #203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
108 changes: 108 additions & 0 deletions
108
report-app/src/app/pages/report-viewer/repair-attempt-graph-builder.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| import {RunInfoFromReportServer} from '../../../../../runner/shared-interfaces'; | ||
| import {BuildResultStatus} from '../../../../../runner/workers/builder/builder-types'; | ||
| import {ScoreCssVariable} from '../../shared/scoring'; | ||
| import {StackedBarChartData} from '../../shared/visualization/stacked-bar-chart/stacked-bar-chart'; | ||
|
|
||
| /** | ||
| * Calculates the average number of repair attempts performed in a run. | ||
| */ | ||
| export function calculateAverageRepairAttempts(report: RunInfoFromReportServer) { | ||
| let totalRepairs = 0; | ||
| let count = 0; | ||
|
|
||
| for (const result of report.results) { | ||
| // Only consider successful builds that required repairs. | ||
| if ( | ||
| result.finalAttempt.buildResult.status === BuildResultStatus.SUCCESS && | ||
| result.repairAttempts > 0 | ||
| ) { | ||
| totalRepairs += result.repairAttempts; | ||
| count++; | ||
| } | ||
| } | ||
|
|
||
| return count > 0 ? totalRepairs / count : null; | ||
| } | ||
|
|
||
| /** | ||
| * Creates graph data for the "repair attempt" graph, from a given run report. | ||
| */ | ||
| export function createRepairAttemptGraphData(report: RunInfoFromReportServer) { | ||
| const repairsToAppCount = new Map<number | 'failed', number>(); | ||
|
|
||
| // Map repair count to how many applications shared that count. | ||
| let maxRepairCount = 0; | ||
| for (const result of report.results) { | ||
| if (result.finalAttempt.buildResult.status === BuildResultStatus.ERROR) { | ||
| repairsToAppCount.set('failed', (repairsToAppCount.get('failed') || 0) + 1); | ||
| } else { | ||
| const repairs = result.repairAttempts; | ||
| // For this graph, we ignore applications that required no repair. | ||
| if (repairs > 0) { | ||
| repairsToAppCount.set(repairs, (repairsToAppCount.get(repairs) || 0) + 1); | ||
| maxRepairCount = Math.max(maxRepairCount, repairs); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| const data: StackedBarChartData = []; | ||
|
|
||
| // All the numeric keys, sorted by value. | ||
| const intermediateRepairKeys = Array.from(repairsToAppCount.keys()) | ||
| .filter((k): k is number => typeof k === 'number') | ||
| .sort((a, b) => a - b); | ||
|
|
||
| // This graph might involve a bunch of sections. We want to scale them among all the possible color "grades". | ||
|
|
||
| for (let repairCount = 1; repairCount <= maxRepairCount; repairCount++) { | ||
| const applicationCount = repairsToAppCount.get(repairCount); | ||
| if (!applicationCount) continue; | ||
|
|
||
| data.push({ | ||
| label: labelByRepairCount(repairCount), | ||
| color: colorByRepairCount(repairCount), | ||
| value: applicationCount, | ||
| }); | ||
| } | ||
|
|
||
| // Handle 'Build failed even after all retries' - always maps to the "failure" grade. | ||
| const failedCount = repairsToAppCount.get('failed') || 0; | ||
| if (failedCount > 0) { | ||
| data.push({ | ||
| label: 'Build failed even after all retries', | ||
| color: ScoreCssVariable.poor, | ||
| value: failedCount, | ||
| }); | ||
| } | ||
| return data; | ||
| } | ||
|
|
||
| function labelByRepairCount(repairCount: number): string { | ||
| switch (repairCount) { | ||
| case 1: | ||
| return '1 repair'; | ||
| case 2: | ||
| case 3: | ||
| case 4: | ||
| return `${repairCount} repairs`; | ||
| default: | ||
| return '5+ repairs'; | ||
| } | ||
| } | ||
|
|
||
| function colorByRepairCount(repairCount: number): string { | ||
| // We're using mediocre1-5 since these are essentially *all* bad so we don't want green in this | ||
| // graph. | ||
| switch (repairCount) { | ||
| case 1: | ||
| return ScoreCssVariable.mediocre1; | ||
| case 2: | ||
| return ScoreCssVariable.mediocre2; | ||
| case 3: | ||
| return ScoreCssVariable.mediocre3; | ||
| case 4: | ||
| return ScoreCssVariable.mediocre4; | ||
| default: | ||
| return ScoreCssVariable.mediocre5; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ | |
|
|
||
| &.multiline-tooltip::before { | ||
| white-space: normal; | ||
| width: max-content; | ||
| max-width: 400px; | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.