function commerce_reports_handler_field_date::post_execute in Commerce Reporting 7.3
Interpolates the missing dates linearly.
Overrides views_handler::post_execute
File
- includes/
views/ commerce_reports_handler_field_date.inc, line 248 - Views field handler for the created date on orders.
Class
- commerce_reports_handler_field_date
- @file Views field handler for the created date on orders.
Code
function post_execute(&$values) {
$retrieved = array();
foreach ($values as $record) {
$timestamp = $this
->convertTimestamp($record->{$this->field_alias});
$record->{$this->field_alias} = $timestamp;
$retrieved[$timestamp] = $record;
}
// Determine order direction.
foreach ($this->query->orderby as $order) {
if ($order['field'] == $this->field_alias) {
$descending = $order['direction'] == 'DESC';
break;
}
}
// If there is no order direction, then we don't need interpolation.
if (!isset($descending)) {
return;
}
$interval = $this
->getInterval();
$defaults = array();
for ($current = $this->startDate; $current <= $this->endDate; $current += $interval) {
$timestamp = $this
->convertTimestamp($current);
$defaults[$timestamp] = (object) array(
$this->field_alias => $timestamp,
);
}
$retrieved += $defaults;
ksort($retrieved);
$values = array_values($retrieved);
}