From dc4640fd30a4c51415cf30211014bc2fdb458315 Mon Sep 17 00:00:00 2001 From: Frank Niessink Date: Sat, 26 Sep 2020 18:21:35 +0200 Subject: [PATCH] Use 'hours' instead of 'minutes' when displaying durations. Fixes #1484. --- components/frontend/src/metric/Measurement.js | 8 ++++++-- components/frontend/src/metric/Measurement.test.js | 4 ++-- docs/CHANGELOG.md | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/components/frontend/src/metric/Measurement.js b/components/frontend/src/metric/Measurement.js index 8e2d2f8ecb..03decaa7f7 100644 --- a/components/frontend/src/metric/Measurement.js +++ b/components/frontend/src/metric/Measurement.js @@ -43,13 +43,17 @@ export function Measurement(props) { return sources.map((source, index) => [index > 0 && ", ", ]) } + 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 = return ( diff --git a/components/frontend/src/metric/Measurement.test.js b/components/frontend/src/metric/Measurement.test.js index 691de0c40b..d73c17e1a8 100644 --- a/components/frontend/src/metric/Measurement.test.js +++ b/components/frontend/src/metric/Measurement.test.js @@ -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', () => { diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index fb04328cac..c34e327b4e 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -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]