Skip to content

Commit 0cfc173

Browse files
committed
fix: PER calculation logic for ratings
1 parent 5097ed1 commit 0cfc173

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

src/components/domain/PerAssessmentSummary/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,9 @@ function PerAssessmentSummary(props: Props) {
139139
* "0"(not - reviewed") component values
140140
*/
141141
const filteredComponents = areaResponse?.component_responses?.filter(
142-
(component) => isDefined(component?.rating) && component.rating > 1,
142+
(component) => isDefined(component?.rating_details)
143+
&& isDefined(component.rating_details.value)
144+
&& component.rating_details?.value > 1,
143145
) ?? [];
144146

145147
if (filteredComponents.length === 0) {

src/views/AccountMyFormsDref/DrefTableActions/i18n.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"namespace": "accountMyFormsDref",
33
"strings": {
4-
"dropdownActionApproveLabel": "Approve",
4+
"dropdownActionApproveLabel": "Approved",
55
"dropdownActionAllocationFormLabel": "Allocation Form",
66
"dropdownActionAddOpsUpdateLabel": "Add Operational Update",
77
"dropdownActionCreateFinalReportLabel": "Create Final Report",

src/views/CountryPreparedness/index.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,17 @@ export function Component() {
191191
return total / list.length;
192192
}
193193

194+
/* NOTE: The calculation of the average rating is done omitting null or
195+
* "0"(not - reviewed") component values
196+
*/
197+
const filteredComponents = componentList.filter(
198+
(component) => isDefined(component)
199+
&& isDefined(component.rating) && component.rating.value > 1,
200+
);
201+
194202
const ratingByArea = mapToList(
195203
listToGroupList(
196-
componentList.filter((component) => isDefined(component.rating)),
204+
filteredComponents,
197205
(component) => component.area.id,
198206
),
199207
(groupedComponentList) => ({
@@ -207,7 +215,7 @@ export function Component() {
207215
).filter(isDefined);
208216

209217
const averageRating = getAverage(
210-
componentList.map((component) => component.rating?.value),
218+
filteredComponents.map((component) => component.rating?.value),
211219
);
212220

213221
const ratingCounts = mapToList(

0 commit comments

Comments
 (0)