consider the following http request:
GET /defects?group-by=priority
I would like the returned collection(feed) of defects to be grouped by their priority. i.e. the returned feed consists of defects(resources) and group infromation.
I thought about something that will return the groups' titles and count before returning the collection, for example:
<content>
<Group val="High" count="567"/>
<Group val="Medium" count="437"/>
<Group val="Low" count="19"/>
<Defect ,,,,>
<Defect ,,,,>
<Defect ,,,,>
</content>
The problem with such representation is that the queried resource (URL) is defect so the client expects collection of Defects and not the Group element.
I guess one option for solving this problem would be to define a separate groups resource for defects i.e.:
defects/groups?group1=priority
that will return collection of groups and their count, and then the client can query the defects resource for the data itself. But this design is cumbersome and requires extra round trips, not to mention possible consistency problems when defects was added\removed between the call to the group resource and the defects resource.
Bottom line, what is the restful way to return a collection of elements grouped by an attribute?
EDIT I first thought of that this problem should be addressed by the ATOM publishing standard. But even if ATOM had addressed it, I still need to support other representations (XML, JSON) so I am looking for a pattern more inherent in the RESTful approach.