Skip to content

Instantly share code, notes, and snippets.

@martindrapeau
Created October 13, 2011 15:04
Show Gist options
  • Save martindrapeau/1284438 to your computer and use it in GitHub Desktop.
Save martindrapeau/1284438 to your computer and use it in GitHub Desktop.
Planbox Current Iteration Time Report
var stories;
var resources;
function doWork() {
var sums = {};
for (var i=0; i < resources.length; i++) {
var resource = resources[i];
sums[resource.id] = {
name: resource.name,
stories: {},
estimate: 0,
duration: 0
}
}
for (var i=0; i < stories.length; i++) {
var story = stories[i];
// Initialize the sums object for this story
for (var j=0; j < resources.length; j++)
sums[resources[j].id]['stories'][story.id] =
{estimate:0, duration:0};
// Loop through all tasks summing estimate and duration
var tasks = story.tasks;
for (var j=0; j < tasks.length; j++) {
var task = tasks[j];
if (sums[task.resource_id] != undefined) {
sums[task.resource_id]['stories'][story.id].estimate
+= parseFloat(task.estimate);
sums[task.resource_id]['stories'][story.id].duration
+= parseFloat(task.duration);
sums[task.resource_id].estimate
+= parseFloat(task.estimate);
sums[task.resource_id].duration
+= parseFloat(task.duration);
}
}
}
// Dump a summary per resource
console.log(sums);
}
// Pull data from Planbox and then call our function
// to summarize...
$.post('https://www.planbox.com/api/get_stories',
{product_id:1234, timeframe:['current']},
function(data) {
stories = data.content;
$.post('https://www.planbox.com/api/get_resources',
{product_id:1234},
function(data) {
resources = data.content;
doWork();
},
'json'
);
},
'json'
);
@martindrapeau
Copy link
Author

Constructs a time report for the Current iteration for each resource in Planbox.
Does so by fetching all stories in the Current iteration, then all resources on the product.
Once data is loaded from Planbox, the doWork function is called.
It creates a sum of estimated and logged time (duration) for each resource.
In addition it sums estimated and logged time for each story.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment