protected function StatusReportController::getPercentByTotals in Acquia Content Hub 8.2
Returns percentage of imported entities over the total entities in the CDF.
Parameters
array $data: The metrics data array of entities in various states from the CDF.
string $type: The type of metrics to get.
Return value
string Percentage of imported entities
Throws
\Exception
1 call to StatusReportController::getPercentByTotals()
- StatusReportController::calculateProgress in modules/
acquia_contenthub_publisher/ src/ Controller/ StatusReportController.php - Calculate import and export progress of current client.
File
- modules/
acquia_contenthub_publisher/ src/ Controller/ StatusReportController.php, line 453
Class
- StatusReportController
- Controller for Status Reports.
Namespace
Drupal\acquia_contenthub_publisher\ControllerCode
protected function getPercentByTotals(array $data, string $type = 'subscriber') {
if (empty($data)) {
return FALSE;
}
$type = $type === 'subscriber' ? 'imported' : 'confirmed';
if (empty($data[$type])) {
return 0;
}
$numerator = $data[$type];
$total = array_sum($data);
$percent = $total > 0 ? round($numerator / $total * 100) : '0';
return $percent;
}