Skip to content

Commit

Permalink
Use 'hours' instead of 'minutes' when displaying durations. Fixes #1484.
Browse files Browse the repository at this point in the history
  • Loading branch information
fniessink committed Sep 26, 2020
1 parent e53f8e2 commit dc4640f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
8 changes: 6 additions & 2 deletions components/frontend/src/metric/Measurement.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,17 @@ export function Measurement(props) {
return sources.map((source, index) => [index > 0 && ", ", <SourceStatus key={source.source_uuid} source_uuid={source.source_uuid}
metric={metric} source={source} datamodel={props.datamodel} />])
}
function get_metric_unit() {
const metric_unit_prefix = metric.scale === "percentage" ? "% " : " ";
const metric_type_unit = metric_type.unit === 'minutes' && metric.scale !== 'percentage' ? 'hours' : metric_type.unit;
return `${metric_unit_prefix}${metric.unit || metric_type_unit}`;
}
const metric = props.report.subjects[props.subject_uuid].metrics[props.metric_uuid];
const metric_type = props.datamodel.metrics[metric.type];
const latest_measurements = metric.recent_measurements;
const latest_measurement = latest_measurements.length > 0 ? latest_measurements[latest_measurements.length - 1] : null;
const sources = (latest_measurement && latest_measurement.sources) || [];
const metric_unit_prefix = metric.scale === "percentage" ? "% " : " ";
const metric_unit = `${metric_unit_prefix}${metric.unit || metric_type.unit}`;
const metric_unit = get_metric_unit();
const metric_name = get_metric_name(metric, props.datamodel);
const details = <MeasurementDetails measurement={latest_measurement} metric_name={metric_name} scale={metric.scale} unit={metric_unit} {...props} />
return (
Expand Down
4 changes: 2 additions & 2 deletions components/frontend/src/metric/Measurement.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ it('renders the metric', () => {
it('renders the minutes', () => {
report.subjects.subject_uuid.metrics.metric_uuid.type = "stability";
const wrapper = measurement();
expect(wrapper.find("TableCell").at(4).text()).toBe("0:50 minutes");
expect(wrapper.find("TableCell").at(5).text()).toBe("≦ 0:00 minutes");
expect(wrapper.find("TableCell").at(4).text()).toBe("0:50 hours");
expect(wrapper.find("TableCell").at(5).text()).toBe("≦ 0:00 hours");
});

it('renders the minutes as percentage', () => {
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Fixed

- The measurement value and target of metrics with unit minutes and their scale set to percentage were formatted incorrectly (e.g. "0:50%" instead of "50%"). Fixes [#1480](https://github.com/ICTU/quality-time/issues/1480).
- The measurement value and target of metrics with unit minutes and their scale set to count were displayed as '`hours`:`minutes` minutes'. This would be confusing: e.g. '3:10 minutes' looks like 3 minutes and 10 seconds instead of 3 hours and 10 minutes. Fixed by changing 'minutes' to 'hours'. Fixes [#1484](https://github.com/ICTU/quality-time/issues/1484).
- The security warnings in OWASP ZAP reports do not have unique keys. However, *Quality-time* needs security warnings to be uniquely identifiable to detect whether the list of warnings changes between measurements. Therefore, *Quality-time* generates keys for OWASP ZAP security warnings itself. Unfortunately, the key that *Quality-time* generated, was not guaranteed to be unique. NB: an unfortunate side effect of the fix is that any OWASP ZAP security warning marked as false positive, confirmed, fixed, or won't fix will return to the unconfirmed state. Fixes [#1492](https://github.com/ICTU/quality-time/issues/1492).

## [3.6.0] - [2020-09-19]
Expand Down

0 comments on commit dc4640f

Please sign in to comment.