protected function DatabaseAggregatorSensorPlugin::getOldestEntry in Monitoring 8
Get the timestamp of the oldest entry that fits owr conditions.
Return value
\Drupal\Core\Database\Query\Select The timestamp of the oldest entry.
1 call to DatabaseAggregatorSensorPlugin::getOldestEntry()
- DatabaseAggregatorSensorPlugin::verboseResultHistory in src/
Plugin/ monitoring/ SensorPlugin/ DatabaseAggregatorSensorPlugin.php - Adds history verbose output to the render array $output.
File
- src/
Plugin/ monitoring/ SensorPlugin/ DatabaseAggregatorSensorPlugin.php, line 216 - Contains \Drupal\monitoring\Plugin\monitoring\SensorPlugin\DatabaseAggregatorSensorPlugin.
Class
- DatabaseAggregatorSensorPlugin
- Database aggregator able to query a single db table.
Namespace
Drupal\monitoring\Plugin\monitoring\SensorPluginCode
protected function getOldestEntry() {
/* @var \Drupal\Core\Database\Connection $database */
$database = $this
->getService('database');
$query = $database
->select($this->sensorConfig
->getSetting('table'));
// Add conditions.
foreach ($this
->getConditions() as $condition) {
$this
->translateCondition($condition, $query);
$query
->condition($condition['field'], $condition['value'], isset($condition['operator']) ? $condition['operator'] : NULL);
}
// Get the oldest entry.
$query
->addExpression('MIN(' . $this
->getTimeIntervalField() . ')', 'timestamp');
return $query
->range(0, 1)
->execute()
->fetchField();
}