First, I love views. Thank you for the main thing that makes my customizations easier.
I'd like to know if its possible to extend the existing view module by adding in support for non-Count aggregates. Specifically, I'd like to add in support for MAX and MIN so that I can create a list of Recent blog posts, from all registered users on the site, where I expect to return 1 blog post per user.
If I had could write a view that uses MAX I could simply return apply a filter or set of filters that return the maximum node id per user for a set of nodes with a type of blog post.
I think I understand how the views module is structured enough to write this myself. But I'd like to know if I'm about to duplicate work that others have done in the past.
A few key points:
1. You already have support for grouping.
2. You already have special cases for things like distinct
3. Supporting aggregate functions would be easier than the work already done to support distinct, as all I'd have to do is write a set of functions that puts something like "MAX(this)" into the fields array.
correct me if i'm wrong.
Comments
Comment #1
cosmicdreams commentedHere's what I'm thinking of :
added to views_node.inc...
...in the filter part of node_views_tables()...
...as a new function in views_node.inc...
...in views_query.inc
Obviously there is a lot of work and bugs created by this change, but its a start
Comment #2
q_man commentedSince you are including some code and prepared to do some work on this I have changed the status to patch (code needs review).
Hopefully this will mean that the project mods will be more keen to look at it and reply.
This is also a feature I would love to have in views since I would like to use it to build a custom image gallery with one image from each user in a list of users.
Comment #3
merlinofchaos commentedThis isn't 2.x =)
Comment #4
q_man commentedHi merlinofchaos,
Good to see you stopped by this post.
Did you correct it to apply to 5.x-1.x-dev?
If so does your lack of other comments mean that because of this it is not a priority or that you have simply no interest in developing this functionality in Views?
This would solve so many setup problems for my clubs site we would be prepared to offer a bounty of $100USD for anyone who sucessfully creates a patch to achieve the above functionality which gets included in a future release of Views (Ideally 2.0 as we will be upgrading when Drupal 6 and views 2 final are released)
Comment #5
merlinofchaos commentedSorry, cosmicdream; the lack of response did indicate that this is not high on my radar. I'm not closing this down, though, but I admit it's something I'm unlikely to put much work into on my own for now.
Comment #6
tommo commentedsubscribing - hope to help later if i can
Comment #7
sunToo much for 5.x. Dunno, whether this still makes sense for 6.x.
Comment #8
eriktoyra commentedSubscribing... this would be a very useful feature. I must have this to sort out the latest unmoderated revision of a node in a view using the Revision Moderation module. For that I need to use MAX(). GROUP BY will only give me the second latest revision for some reason...
Comment #9
lunaris commentedHi guys,
I've attempted a patch for this problem that's attached to #396380: Enhance Views to support proper GROUP BY queries -- this seems to be the master issue for grouping and aggregation in views. It's not much yet, but hopefully this'll go somewhere.
lunaris
Comment #10
merlinofchaos commentedMarking dup, it's really just another group by need.