You are here

public function AcquiaContentHubStatusMetricsTrait::getMostRecentUpdateTime in Acquia Content Hub 8.2

Calculates updated time of most recent published tracked entity.

Return value

false|int Timestamp of most recent record

1 call to AcquiaContentHubStatusMetricsTrait::getMostRecentUpdateTime()
AcquiaContentHubStatusMetricsTrait::getStatusMetrics in src/AcquiaContentHubStatusMetricsTrait.php
Calculates metrics timestamped and indexed by status.

File

src/AcquiaContentHubStatusMetricsTrait.php, line 55

Class

AcquiaContentHubStatusMetricsTrait
Trait to set status metrics for Content Hub client cdf entities.

Namespace

Drupal\acquia_contenthub

Code

public function getMostRecentUpdateTime($table_name, $modified_column_name) {
  $query = $this->database
    ->select($table_name, 't')
    ->fields('t', [
    $modified_column_name,
  ])
    ->orderBy($modified_column_name, 'DESC')
    ->range(0, 1);
  $last_updated_record = $query
    ->execute()
    ->fetchAll(\PDO::FETCH_ASSOC);
  $updateTime = !empty($last_updated_record) ? strtotime($last_updated_record[0][$modified_column_name]) : 0;
  return $updateTime;
}