function date_api_argument_handler::summary_query in Date 6.2
Same name and namespace in other branches
- 6 date_api.views.inc \date_api_argument_handler::summary_query()
Create a summary query that matches the granularity.
Needed or Views will do a groupby on the complete date instead of only the part of the date actually used in the argument.
File
- includes/
date_api_argument_handler.inc, line 241 - Views argument handler.
Class
- date_api_argument_handler
- Date API argument handler.
Code
function summary_query() {
$this
->get_query_fields();
// No way to do summaries on more than one field at a time.
if (count($this->query_fields) > 1) {
return;
}
// Cause query->ensure_table to perform the correct join.
$this->table = $this->query_fields[0]['field']['table_name'];
$this
->ensure_my_table();
$field = $this->query_fields[0]['field'];
$date_handler = $this->query_fields[0]['date_handler'];
// Get the SQL format for this granularity, like Y-m,
// and use that as the grouping value.
$format = $date_handler
->views_formats($this->options['granularity'], 'sql');
$this->formula = $date_handler
->sql_format($format, $date_handler
->sql_field($field['fullname']));
// Add the computed field.
$this->base_alias = $this->name_alias = $this->query
->add_field(NULL, $this->formula, $field['query_name']);
return $this
->summary_basics(FALSE);
}