Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 35 additions & 27 deletions lib/Service/ArchiMateImportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -1142,11 +1142,11 @@ private function saveObjectsInParallelBatches(array $objects, ObjectService $obj
$allResults = [];
$processedChunks = 0;

// Accumulate statistics from all chunks
// Accumulate statistics from all chunks (using new format)
$aggregatedStats = [
'saved' => [],
'updated' => [],
'skipped' => [],
'unchanged' => [],
'invalid' => []
];

Expand All @@ -1170,16 +1170,18 @@ private function saveObjectsInParallelBatches(array $objects, ObjectService $obj
events: !self::PERFORMANCE_OPTIMIZATIONS['disable_events']
);



// Calculate totals received back from this chunk
$chunkTotalReceived = count($saveResult['saved'] ?? []) +
count($saveResult['updated'] ?? []) +
count($saveResult['skipped'] ?? []) +
count($saveResult['unchanged'] ?? []) +
count($saveResult['invalid'] ?? []);

// Accumulate statistics from this chunk
$aggregatedStats['saved'] = array_merge($aggregatedStats['saved'], $saveResult['saved'] ?? []);
$aggregatedStats['updated'] = array_merge($aggregatedStats['updated'], $saveResult['updated'] ?? []);
$aggregatedStats['skipped'] = array_merge($aggregatedStats['skipped'], $saveResult['skipped'] ?? []);
$aggregatedStats['unchanged'] = array_merge($aggregatedStats['unchanged'], $saveResult['unchanged'] ?? []);
$aggregatedStats['invalid'] = array_merge($aggregatedStats['invalid'], $saveResult['invalid'] ?? []);

$savedObjects = array_merge(
Expand All @@ -1200,7 +1202,7 @@ private function saveObjectsInParallelBatches(array $objects, ObjectService $obj
'objects_lost_in_chunk' => $chunkInputCount - $chunkTotalReceived,
'chunk_saved' => count($saveResult['saved'] ?? []),
'chunk_updated' => count($saveResult['updated'] ?? []),
'chunk_skipped' => count($saveResult['skipped'] ?? []),
'chunk_unchanged' => count($saveResult['unchanged'] ?? []),
'chunk_invalid' => count($saveResult['invalid'] ?? [])
]);

Expand All @@ -1221,7 +1223,7 @@ private function saveObjectsInParallelBatches(array $objects, ObjectService $obj
// Store the aggregated result for statistics calculation
$this->lastSaveResult = $aggregatedStats;

$totalObjectsProcessed = count($aggregatedStats['saved']) + count($aggregatedStats['updated']) + count($aggregatedStats['skipped']) + count($aggregatedStats['invalid']);
$totalObjectsProcessed = count($aggregatedStats['saved']) + count($aggregatedStats['updated']) + count($aggregatedStats['unchanged']) + count($aggregatedStats['invalid']);

$this->logger->info('Optimized batch processing completed', [
'INPUT_SUMMARY' => [
Expand All @@ -1239,7 +1241,7 @@ private function saveObjectsInParallelBatches(array $objects, ObjectService $obj
'total_chunks_processed' => $totalChunks,
'aggregated_saved' => count($aggregatedStats['saved']),
'aggregated_updated' => count($aggregatedStats['updated']),
'aggregated_skipped' => count($aggregatedStats['skipped']),
'aggregated_unchanged' => count($aggregatedStats['unchanged']),
'aggregated_invalid' => count($aggregatedStats['invalid'])
]
]);
Expand Down Expand Up @@ -1283,6 +1285,8 @@ private function saveObjectsInSingleBatch(array $objects, ObjectService $objectS
events: !self::PERFORMANCE_OPTIMIZATIONS['disable_events']
);



// Store the save result for later access to statistics
$this->lastSaveResult = $saveResult;

Expand All @@ -1296,7 +1300,7 @@ private function saveObjectsInSingleBatch(array $objects, ObjectService $objectS
$this->logger->info('Objects saved successfully', [
'saved_count' => count($saveResult['saved'] ?? []),
'updated_count' => count($saveResult['updated'] ?? []),
'skipped_count' => count($saveResult['skipped'] ?? []),
'unchanged_count' => count($saveResult['unchanged'] ?? []),
'invalid_count' => count($saveResult['invalid'] ?? []),
'error_count' => count($saveResult['errors'] ?? []),
'total_processed' => $saveResult['statistics']['totalProcessed'] ?? 0
Expand All @@ -1313,12 +1317,12 @@ private function saveObjectsInSingleBatch(array $objects, ObjectService $objectS
}
}

// Log details about skipped objects if any
if (!empty($saveResult['skipped'])) {
$this->logger->info('Objects skipped during import (no changes detected)', [
'skipped_count' => count($saveResult['skipped']),
'sample_skipped_ids' => array_slice(
array_map(fn($obj) => $obj->getUuid() ?? 'unknown', $saveResult['skipped']),
// Log details about unchanged objects if any
if (!empty($saveResult['unchanged'])) {
$this->logger->info('Objects unchanged during import (no changes detected)', [
'unchanged_count' => count($saveResult['unchanged']),
'sample_unchanged_ids' => array_slice(
array_map(fn($obj) => $obj->getUuid() ?? 'unknown', $saveResult['unchanged']),
0,
5
)
Expand Down Expand Up @@ -1712,33 +1716,36 @@ private function calculateOptimizedStatistics(array $savedObjects): array
'total_objects_created' => 0,
'total_objects_updated' => 0,
'total_objects_deleted' => 0,
'total_objects_skipped' => 0,
'total_objects_unchanged' => 0,
'total_errors' => 0
]
];

if ($this->lastSaveResult !== null) {
$saveResult = $this->lastSaveResult;



$statistics['summary'] = [
'total_objects_created' => count($saveResult['saved'] ?? []),
'total_objects_updated' => count($saveResult['updated'] ?? []),
'total_objects_deleted' => 0,
'total_objects_skipped' => count($saveResult['skipped'] ?? []),
'total_objects_unchanged' => count($saveResult['unchanged'] ?? $saveResult['skipped'] ?? []),
'total_errors' => count($saveResult['invalid'] ?? [])
];

// Log detailed breakdown of results
$totalStatisticsCount = array_sum([
count($saveResult['saved'] ?? []),
count($saveResult['updated'] ?? []),
count($saveResult['skipped'] ?? []),
count($saveResult['unchanged'] ?? $saveResult['skipped'] ?? []),
count($saveResult['invalid'] ?? [])
]);

$this->logger->info('Import statistics breakdown', [
'created' => count($saveResult['saved'] ?? []),
'updated' => count($saveResult['updated'] ?? []),
'skipped' => count($saveResult['skipped'] ?? []),
'unchanged' => count($saveResult['unchanged'] ?? $saveResult['skipped'] ?? []),
'invalid' => count($saveResult['invalid'] ?? []),
'total_in_statistics' => $totalStatisticsCount
]);
Expand Down Expand Up @@ -3821,11 +3828,11 @@ private function calculateObjectStatistics(array $normalizedData, array $savedOb
{
// Initialize statistics structure
$statistics = [
'elements' => ['created' => 0, 'updated' => 0, 'skipped' => 0, 'errors' => []],
'organizations' => ['created' => 0, 'updated' => 0, 'skipped' => 0, 'errors' => []],
'relationships' => ['created' => 0, 'updated' => 0, 'skipped' => 0, 'errors' => []],
'views' => ['created' => 0, 'updated' => 0, 'skipped' => 0, 'errors' => []],
'property_definitions' => ['created' => 0, 'updated' => 0, 'skipped' => 0, 'errors' => []]
'elements' => ['created' => 0, 'updated' => 0, 'unchanged' => 0, 'errors' => []],
'organizations' => ['created' => 0, 'updated' => 0, 'unchanged' => 0, 'errors' => []],
'relationships' => ['created' => 0, 'updated' => 0, 'unchanged' => 0, 'errors' => []],
'views' => ['created' => 0, 'updated' => 0, 'unchanged' => 0, 'errors' => []],
'property_definitions' => ['created' => 0, 'updated' => 0, 'unchanged' => 0, 'errors' => []]
];

// If we have access to the actual save results from ObjectService, use those
Expand All @@ -3836,7 +3843,7 @@ private function calculateObjectStatistics(array $normalizedData, array $savedOb
$allProcessedObjects = array_merge(
$saveResult['saved'] ?? [],
$saveResult['updated'] ?? [],
$saveResult['skipped'] ?? [],
$saveResult['unchanged'] ?? $saveResult['skipped'] ?? [],
// For invalid objects, extract the original object from the error structure
array_map(fn($item) => $item['object'] ?? [], $saveResult['invalid'] ?? [])
);
Expand Down Expand Up @@ -3874,9 +3881,10 @@ private function calculateObjectStatistics(array $normalizedData, array $savedOb
$wasUpdated = !empty(array_filter($saveResult['updated'] ?? [],
fn($updated) => ($updated->getUuid() === $objectId)));

// Check if this object was skipped (no changes)
$wasSkipped = !empty(array_filter($saveResult['skipped'] ?? [],
fn($skipped) => ($skipped->getUuid() === $objectId)));
// Check if this object was unchanged (no changes)
$unchangedObjects = $saveResult['unchanged'] ?? $saveResult['skipped'] ?? [];
$wasSkipped = !empty(array_filter($unchangedObjects,
fn($unchanged) => ($unchanged->getUuid() === $objectId)));

// Check if this object had validation errors
$hasErrors = !empty(array_filter($saveResult['invalid'] ?? [],
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/ArchiMateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ private function saveObjectsInSingleBatch(array $objects, ObjectService $objectS
$this->logger->info('Objects saved successfully', [
'saved_count' => count($saveResult['saved'] ?? []),
'updated_count' => count($saveResult['updated'] ?? []),
'skipped_count' => count($saveResult['skipped'] ?? []),
'unchanged_count' => count($saveResult['skipped'] ?? []),
'invalid_count' => count($saveResult['invalid'] ?? []),
'error_count' => count($saveResult['errors'] ?? []),
'total_processed' => $saveResult['statistics']['totalProcessed'] ?? 0
Expand Down
8 changes: 4 additions & 4 deletions src/views/settings/sections/ArchiMateImportExport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@
Updated
</div>
</div>
<div class="summary-item skipped">
<div class="summary-item unchanged">
<div class="summary-number">
{{ importResult.statistics.summary.total_objects_skipped }}
{{ importResult.statistics.summary.total_objects_unchanged }}
</div>
<div class="summary-label">
Skipped
Unchanged
</div>
</div>
<div class="summary-item errors">
Expand Down Expand Up @@ -872,7 +872,7 @@ export default {
background: var(--color-warning-light);
}

.summary-item.skipped {
.summary-item.unchanged {
border-color: var(--color-text-lighter);
background: var(--color-background-hover);
}
Expand Down