Skip to content

Commit

Permalink
Add count_skips field to Importance by Component widget
Browse files Browse the repository at this point in the history
  • Loading branch information
Fynardo committed Oct 28, 2024
1 parent cad42c6 commit 08f6e73
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
7 changes: 7 additions & 0 deletions backend/ibutsu_server/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,13 @@
"default": 5,
"required": False,
},
{
"name": "count_skips",
"description": "Count skips against the pass rate.",
"type": "boolean",
"required": False,
"default": False,
},
],
"type": "widget",
},
Expand Down
6 changes: 4 additions & 2 deletions backend/ibutsu_server/widgets/importance_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def get_importance_component(
builds=5,
components="",
project=None,
count_skips=False,
):
# taken from get_jenkins_line_chart in jenkins_job_analysis.py
run_limit = int((JJV_RUN_LIMIT / BARCHART_MAX_BUILDS) * builds)
Expand Down Expand Up @@ -91,15 +92,16 @@ def get_importance_component(
sdatdict[component][bnum][importance] = []

# this is to change result values into numbers
# TODO: This doesn't handle xpassed, xfailed, skipped, etc. so figure that out
# TODO: This now handles skipped, but not xpassed or xfailed.
for component in sdatdict.keys():
for bnum in sdatdict[component].keys():
for importance in sdatdict[component][bnum].keys():
total = 0
passed = 0
res_list = []
for item in sdatdict[component][bnum][importance]:
total += 1
if count_skips or (not item["result"] == "skipped"):
total += 1
res_list.append(item["result_id"])
if item["result"] == "passed":
passed += 1
Expand Down
19 changes: 18 additions & 1 deletion frontend/src/widgets/importancecomponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
import {
Card,
CardBody,
CardFooter,
Text
} from '@patternfly/react-core';

Expand All @@ -20,7 +21,7 @@ import { Link } from 'react-router-dom';

import { HttpClient } from '../services/http';
import { Settings } from '../settings';
import { WidgetHeader } from '../components/widget-components';
import { ParamDropdown, WidgetHeader } from '../components/widget-components';

export class ImportanceComponentWidget extends React.Component {
static propTypes = {
Expand All @@ -39,6 +40,7 @@ export class ImportanceComponentWidget extends React.Component {
table_data: []
},
isLoading: true,
countSkips: 'No',
};
}

Expand Down Expand Up @@ -70,6 +72,13 @@ export class ImportanceComponentWidget extends React.Component {
}
}

onSkipSelect = (value) => {
this.setState({countSkips: value}, () => {
this.props.params.count_skips = (value === 'Yes');
this.getData();
});
}

toPercent(num) {
if (typeof(num) === 'number') {
return Math.round(num * 100)
Expand Down Expand Up @@ -114,6 +123,14 @@ export class ImportanceComponentWidget extends React.Component {
))}
</CardBody>
}
<CardFooter>
<ParamDropdown
dropdownItems={['Yes', 'No']}
handleSelect={this.onSkipSelect}
defaultValue={this.state.countSkips}
tooltip="Count skips as failure:"
/>
</CardFooter>
</Card>
);
}
Expand Down

0 comments on commit 08f6e73

Please sign in to comment.