You are here

protected function StatusReportController::calculateProgress in Acquia Content Hub 8.2

Calculate import and export progress of current client.

Parameters

array $client: Current client.

array $interests: Webhook uuid of client.

array $client_type: Array of client types.

Return value

array Statuses for publisher and subscriber.

Throws

\Exception

1 call to StatusReportController::calculateProgress()
StatusReportController::getWebhooksPageSection in modules/acquia_contenthub_publisher/src/Controller/StatusReportController.php
Returns the Webhooks page section.

File

modules/acquia_contenthub_publisher/src/Controller/StatusReportController.php, line 363

Class

StatusReportController
Controller for Status Reports.

Namespace

Drupal\acquia_contenthub_publisher\Controller

Code

protected function calculateProgress(array $client, array $interests, array $client_type) {
  $client_status = [];
  foreach ($client_type as $type) {
    $type = strtolower($type);
    $data_type = 'data';
    if (isset($client['metadata']['metrics'][$type]) && !empty($interests) && !empty($client['metadata']['metrics'][$type][$data_type])) {
      $client_metrics = $client['metadata']['metrics'][$type];
      $percent = $this
        ->getPercentByTotals($client_metrics[$data_type] ?? [], $type);
      $client_status[$type] = $this
        ->t('<span class="percent">@percent@label</span><progress max="100" value="@percent"></progress>', [
        '@percent' => $percent,
        '@label' => '%',
      ]);
    }
  }
  return $client_status;
}