Skip to content

Commit 8a8e88c

Browse files
committed
fix: exclude components with component.rating = 1 from average calculation
1 parent 32ccc19 commit 8a8e88c

File tree

1 file changed

+5
-4
lines changed
  • app/src/components/domain/PerAssessmentSummary

1 file changed

+5
-4
lines changed

app/src/components/domain/PerAssessmentSummary/index.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,10 @@ function PerAssessmentSummary(props: Props) {
161161
(areaResponse) => {
162162
// NOTE: do we take the average of only rated components or of all the
163163
// components?
164+
// Also, 'component.rating' refers to the component ID and is misnamed.
164165
const filteredComponents = areaResponse?.component_responses?.filter(
165-
(component) => isDefined(component?.rating_details?.value)
166-
&& component.rating_details.value !== 0,
166+
(component) => isDefined(component?.rating)
167+
&& component.rating !== 1,
167168
) ?? [];
168169

169170
if (filteredComponents.length === 0) {
@@ -172,8 +173,8 @@ function PerAssessmentSummary(props: Props) {
172173

173174
const ratings = filteredComponents.map(
174175
(component) => (
175-
isDefined(component.rating_details?.value)
176-
? component.rating_details.value
176+
isDefined(component.rating)
177+
? ratingIdToValueMap?.[component.rating]
177178
: 0
178179
),
179180
);

0 commit comments

Comments
 (0)