Skip to content

Commit

Permalink
fix: exclude components with component.rating = 1 from average calc…
Browse files Browse the repository at this point in the history
…ulation
  • Loading branch information
samshara committed Oct 17, 2024
1 parent 32ccc19 commit 8a8e88c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions app/src/components/domain/PerAssessmentSummary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,10 @@ function PerAssessmentSummary(props: Props) {
(areaResponse) => {
// NOTE: do we take the average of only rated components or of all the
// components?
// Also, 'component.rating' refers to the component ID and is misnamed.
const filteredComponents = areaResponse?.component_responses?.filter(
(component) => isDefined(component?.rating_details?.value)
&& component.rating_details.value !== 0,
(component) => isDefined(component?.rating)
&& component.rating !== 1,
) ?? [];

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

const ratings = filteredComponents.map(
(component) => (
isDefined(component.rating_details?.value)
? component.rating_details.value
isDefined(component.rating)
? ratingIdToValueMap?.[component.rating]
: 0
),
);
Expand Down

0 comments on commit 8a8e88c

Please sign in to comment.