Closed regedarek closed 10 years ago
var pivotal = require("../index.js"),
async = require("async"),
colors = require("colors"),
token = process.env.token || null,
debug = (process.env.debug !== undefined);
pivotal.debug = debug;
pivotal.useToken(token);
app.get('/delivered_stories', function(request, response) {
function get_stories(project_ids) {
var results = [];
async.each(project_ids, function(id, cb) {
pivotal.getStories(id, { filter: "state:finished" }, function(err, project_stories) {
if (err) {
return console.error("project: ", id, ", getStories ERROR", err);
}
// this is just in, but empty results will return null
if (!project_stories) {
return console.log("Project: ".green, id, ", stories: ".blue, "0");
}
console.log("Project: ".green, id, ", stories: ".blue, project_stories.story.length);
results = results.concat(project_stories.story);
cb();
});
}, function () {
// This will send what you want
response.send(results);
}),
// This will send an empty array - use async, step or something
// response.send(results);
}
pivotal.getProjects(function (err, data) {
// check for errors
if (err) {
return console.error("getProject ERROR", err);
}
var project_ids = data.project.map(function(x) {
return parseInt(x.id, 10);
});
console.log("ids", project_ids);
get_stories(project_ids);
});
};
I am trying something like this:
Could you help me with that?