You're pretty much on the money with having a "release_id":
"release-uuid" type of link.
First the easy way, then the nifty way/
Get all tasks for release:
// Stored in "_design/tickets" as the "by_release" view
function(doc)
{
if(doc.type == "ticket") emit(doc.release_id, null);
}
Fetching:
http://127.0.0.1:5984/db_name/_view/tickets/by_release?key=release_id
Completed tasks:
// Stored in "_design/tickets" as "completed" view
//Map
function(doc)
{
if(doc.type == "ticket" && doc.status == "completed")
emit(doc.release_id, 1);
}
//Reduce
function(keys, values) {return sum(values);}
Fetching:
http://127.0.0.1:5984/db_name/_view/tickets/completed?group=true?key=release_id
Now the nifty way
//Stored in "_design/tickets" as "by_release" view
//map
function(doc)
{
if(doc.type == "ticket") emit([doc.release_id, doc.status], 1);
}
//reduce
function(keys, values) {return sum(values);}
This will allow us to do a couple things:
Number of tickets in system:
http://127.0.0.1:5984/db_name/_view/by_release
All tickets for release
http://127.0.0.1:5984/db_name/_view/by_release?reduce=false&startkey=["release_id",
null]&endkey=["release_id", {}]
Number of tickets for the release:
http://127.0.0.1:5984/db_name/_view/by_release?group_level=1&key=["release_id"]
Number of tickets for a particular status
http://127.0.0.1:5984/db_name/_view/by_release?group_level=2&key=["release_id",
"status_type"]
At least, I'm pretty sure those would all work. Haven't tested them :)
Paul
On Tue, Dec 16, 2008 at 2:18 PM, Matthew Wilson <[email protected]> wrote:
> I want to build a simple bug-tracking system where I have tasks
> (discrete things to do) and then releases (groups of tasks).
>
> How would I do something like this? Would I make each task have a key
> named "release ID" that has the value of the ID release document?
>
> I want to support views like "get all tasks for this release" as well
> as "get count of completed tasks for each release".
>
> All advice welcome.
>
> --
> Matthew Wilson
> [email protected]
> http://tplus1.com
>