mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-11-01 01:38:23 +00:00
Fix: export actions and their results in csv even when action does not have any goals attached to it.
This commit is contained in:
6
.changes/unreleased/Fixed-20251029-143836.yaml
Normal file
6
.changes/unreleased/Fixed-20251029-143836.yaml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
kind: Fixed
|
||||||
|
body: 'Fix: export actions and their results in csv even when action does not have any goals attached to it.'
|
||||||
|
time: 2025-10-29T14:38:36.195220844+01:00
|
||||||
|
custom:
|
||||||
|
Issue: "453"
|
||||||
|
SchemaChange: No schema change
|
||||||
@@ -42,28 +42,41 @@ final readonly class SocialActionCSVExportService
|
|||||||
$csv->insertOne($headers);
|
$csv->insertOne($headers);
|
||||||
|
|
||||||
foreach ($actions as $action) {
|
foreach ($actions as $action) {
|
||||||
if ($action->getGoals()->isEmpty() && $action->getResults()->isEmpty() && $action->getEvaluations()->isEmpty()) {
|
$hasGoals = !$action->getGoals()->isEmpty();
|
||||||
|
$hasResults = !$action->getResults()->isEmpty();
|
||||||
|
$hasEvaluations = !$action->getEvaluations()->isEmpty();
|
||||||
|
|
||||||
|
// If action has no goals, results, or evaluations, insert a single row
|
||||||
|
if (!$hasGoals && !$hasResults && !$hasEvaluations) {
|
||||||
$csv->insertOne($this->formatRow($action));
|
$csv->insertOne($this->formatRow($action));
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($action->getGoals() as $goal) {
|
// Process goals and their results
|
||||||
if ($goal->getResults()->isEmpty()) {
|
if ($hasGoals) {
|
||||||
$csv->insertOne($this->formatRow($action, $goal));
|
foreach ($action->getGoals() as $goal) {
|
||||||
}
|
if ($goal->getResults()->isEmpty()) {
|
||||||
|
$csv->insertOne($this->formatRow($action, $goal));
|
||||||
foreach ($goal->getResults() as $goalResult) {
|
} else {
|
||||||
$csv->insertOne($this->formatRow($action, $goal, $goalResult));
|
foreach ($goal->getResults() as $goalResult) {
|
||||||
|
$csv->insertOne($this->formatRow($action, $goal, $goalResult));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($action->getResults() as $result) {
|
// Process results that are linked to this action (regardless of whether they have goals elsewhere)
|
||||||
if ($result->getGoals()->isEmpty()) {
|
if ($hasResults && !$hasGoals) {
|
||||||
|
foreach ($action->getResults() as $result) {
|
||||||
$csv->insertOne($this->formatRow($action, null, null, $result));
|
$csv->insertOne($this->formatRow($action, null, null, $result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($action->getEvaluations() as $evaluation) {
|
// Process evaluations
|
||||||
$csv->insertOne($this->formatRow($action, evaluation: $evaluation));
|
if ($hasEvaluations) {
|
||||||
|
foreach ($action->getEvaluations() as $evaluation) {
|
||||||
|
$csv->insertOne($this->formatRow($action, evaluation: $evaluation));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user