Skip to content

Commit 103bea4

Browse files
committed
Change diff logic layer
1 parent 3b3e025 commit 103bea4

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

src/Service/AdminService.php

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,9 +518,31 @@ public function compareOnlineTokensData(): stdClass
518518
$onlineDataPreprod = $this->curlRequest($ENDPOINT_PREPROD, false, $headers);
519519
$onlineDataProd = $this->curlRequest($ENDPOINT_PROD, false, $headers);
520520

521+
$onlineDataPreprod = $this->formatDataForParsing($onlineDataPreprod);
522+
$onlineDataProd = $this->formatDataForParsing($onlineDataProd);
523+
521524
$treeWalker = new TreeWalker([]);
522525

523-
return json_decode($treeWalker->getdiff($onlineDataPreprod, $onlineDataProd, true));
526+
// Get json diff
527+
$filteredResult = $treeWalker->getdiff($onlineDataPreprod, $onlineDataProd, true);
528+
529+
// Remove values
530+
$treeWalker->walker($filteredResult, function(&$struct, $key) {
531+
if ($key == "lastUpdate") {
532+
unset($struct[$key]);
533+
}
534+
});
535+
536+
// Check empty
537+
foreach ($filteredResult as $key => $options) {
538+
foreach ($options as $id => $values) {
539+
if (empty($values)) {
540+
unset($filteredResult[$key][$id]);
541+
}
542+
}
543+
}
544+
545+
return json_decode(json_encode($filteredResult));
524546
}
525547

526548
/**
@@ -588,4 +610,23 @@ private function doAppQuotaMapping(array $applicationsQuota): array
588610

589611
return $result;
590612
}
613+
614+
/**
615+
* Format data for parsing.
616+
*
617+
* @param $jsonData
618+
*
619+
* @return string
620+
*/
621+
private function formatDataForParsing($jsonData): string
622+
{
623+
$orderedArray = [];
624+
625+
$array = json_decode($jsonData);
626+
foreach($array as $value) {
627+
$orderedArray[$value->blockchainAddresses->ethereum->distributor] = $value;
628+
}
629+
630+
return json_encode($orderedArray);
631+
}
591632
}

0 commit comments

Comments
 (0)