Summary, sorted ascending/descending Views2 by Date don't work!
For example: grouping link show as separate elements:
2008 (1)
2008 (1)
2008 (1)
2008 (1)
2008 (1)
2008 (1)
2008 (1)
2007 (1)
2007 (1)
...
instead of show:
2008 (7)
2007 (2)
Why???
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | summary_view.txt | 8.48 KB | terrychild |
Comments
Comment #1
batbug2 commentedHave the same problem, subscribing
Comment #2
fde commentedI have the same behavior (using a cck date field as argument, with a granularity set to either year or month).
Here is the SQL generated by the view, if it can help:
Comment #3
terrychild commentedHi All
I'm having the same problem:
When I try to summarize on the 'node posted date' of an 'event' content type using a views argument of 'Node: Created year + month' (like the default archive view) the view generates the following SQL:
SELECT DATE_FORMAT(FROM_UNIXTIME(node.created), '%Y%m') AS created_year_month,
COUNT(node.nid) AS num_records
FROM node node
WHERE (node.status <> 0) AND (node.type in ('event'))
GROUP BY created_year_month
ORDER BY created_year_month ASC
producing the following when I run the SQL manually:
created_year_month num_records
200812 1
200901 6
This produces the following correct output:
* December, 2008 (1)
* January, 2009 (6)
but when I use an argument of "Date: Date Node: Post" with a granularity of month the view generates the following SQL:
SELECT node.created AS node_created,
COUNT(node.nid) AS num_records
FROM node node
WHERE (node.status <> 0) AND (node.type in ('event'))
GROUP BY node_created
ORDER BY node_created ASC
producing the following when I run the SQL manually:
node_created num_records
1229811551 1
1231809580 1
1231811465 1
1231881708 1
1232488349 1
1232488498 1
1232488593 1
and the following incorrect output:
* January, 2009 (1)
* January, 2009 (1)
* January, 2009 (1)
* January, 2009 (1)
* January, 2009 (1)
* January, 2009 (1)
* January, 2009 (1)
The SQL is practically the same apart from DATE_FORMAT and FROM_UNIXTIME calls which aren't added by the Date module.
I get the same results when trying to create a summary view using a CCK Date field.
I've attached the exported view - the summary is in the 'Monthly Block' display at the end.
Please let me know if I can supply any more info.
Regards
Terry Child
Comment #4
Anonymous (not verified) commentedIt sounds like this may be related to the issue reported at http://drupal.org/node/355571.
(If not, do I need to raise this here as well somehow?)
Regards, Tony
Comment #5
Crell commentedI just ran into the same issue and managed to figure out why.
In date_api_argument_handler::summary_query(), There's this snippet (around line 229 and following in the RC6 release):
What that does is ensure that the necessary tables are part of the query. Then it adds the original, un-mutated date field to the query to... ensure that the tables are included. Then it adds the mutated form of the field, that is, the formatted "Y" or "Y-m" version. Then it does some other stuff.
But wait! Deep down in views_query::add_field, there's this code:
That is, if the alias is already in use it silently skips adding the new field. But the code in the summary_query() is using the same alias as the field itself, so the formatted version gets skipped!
I don't actually think that the first call to add_field() is necessary given the ensure_my_table() call above it. When I commented it out, it still worked fine and I got my proper summary view.
Karen, all yours. :-)
Comment #6
Crell commentedI suspect #307256: Argument Summary display not working is a duplicate.
Comment #7
karens commentedI just posted a change to the argument summary that seems to help get it to group by date and granularity properly and the sorting also works correctly for me. Some of the Views code changed and that changed the way the Date argument needed to react.
If there are problems in the latest -dev code you can reopen.