Skip to content

Commit

Permalink
fix: result completeness only if all results filled up correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
aashish-t-magar committed Jan 17, 2024
1 parent 79a80a9 commit 57d255f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

#php artisan test && \
php artisan test && \
npx stylelint "resources/**/*.scss" --fix && \
npm run lint && \
npx lint-staged && \
Expand Down
11 changes: 9 additions & 2 deletions app/IATI/Services/ElementCompleteService.php
Original file line number Diff line number Diff line change
Expand Up @@ -802,13 +802,13 @@ public function getFormattedResults($activity): array
$periodData = [];

if (!empty($results)) {
foreach ($results as $result) {
foreach ($results as $resultKey => $result) {
$resultData[] = $result['result'];
$indicators = $result['indicators'];
$resultReference = Arr::get($result['result'], 'reference');

if (!empty($indicators)) {
foreach ($indicators as $indicator) {
foreach ($indicators as $indicatorKey => $indicator) {
$indicatorValue = $indicator['indicator'];

if (is_array_value_empty(Arr::get($indicatorValue, 'reference'))) {
Expand All @@ -821,11 +821,18 @@ public function getFormattedResults($activity): array
$periods = $indicator['periods'];

if (!empty($periods)) {
$resultData[$resultKey] = $result['result'];
$indicatorData[$indicatorKey] = $indicatorValue;

foreach ($periods as $period) {
$periodData[] = $period['period'];
}
} else {
$resultData = [];
}
}
} else {
$resultData = [];
}
}
}
Expand Down

0 comments on commit 57d255f

Please sign in to comment.