refactor(inventory): optimize extraction of fwt and spd in CreatePartitionService
ogcore-debian-package/pipeline/head This commit looks good Details
testing/ogcore-api/pipeline/head There was a failure building this commit Details

pull/127/head
Juan Manuel Bardallo 2026-07-31 13:40:29 +02:00
parent 809ecd0d37
commit 33609081bf
1 changed files with 16 additions and 9 deletions

View File

@ -30,20 +30,27 @@ class CreatePartitionService
return isset($cfg['disk'], $cfg['par'], $cfg['tam'], $cfg['uso'], $cfg['fsi']);
});
$fwtFound = false;
$spdFound = false;
foreach ($data['cfg'] as $cfg) {
if (!empty($cfg['fwt'])) {
if (!$fwtFound && !empty($cfg['fwt'])) {
$clientEntity->setFirmwareType($cfg['fwt']);
$this->entityManager->persist($clientEntity);
$fwtFound = true;
}
if (!$spdFound && !empty($cfg['spd'])) {
$clientEntity->setNetSpeed((int) $cfg['spd']);
$spdFound = true;
}
if ($fwtFound && $spdFound) {
break;
}
}
foreach ($data['cfg'] as $cfg) {
if (!empty($cfg['spd'])) {
$clientEntity->setNetSpeed((int) $cfg['spd']);
$this->entityManager->persist($clientEntity);
break;
}
if ($fwtFound || $spdFound) {
$this->entityManager->persist($clientEntity);
}
foreach ($filteredCfg as $cfg) {