Question

I'm trying to fetch all user stories that belong to certain feature, but which have children.

Here's how I created query for that using rally-node.

async.map(features, function(feature, cb) {
  self.restApi.query({
      type: 'hierarchicalrequirement',
      limit: Infinity,
      order: 'Rank',
      fetch: ['FormattedID', 'Name', 'Children'],
      parent: feature.ObjectID,
      query: queryUtils.where('DirectChildrenCount', '>', 0)
 }, cb);
}, function(err, results) {
   //user stories
});

And here's how my feature looks like:

 { _rallyAPIMajor: '2',
_rallyAPIMinor: '0',
_ref: 'https://rally1.rallydev.com/slm/webservice/v2.0/portfolioitem/feature/18846103932',
_refObjectUUID: 'c01d7f828-a6d6-4efc-8160-c0c19ad0fabc',
_objectVersion: '7',
_refObjectName: 'Dashboard Widgets',
ObjectID: 18836103932,
FormattedID: 'F1',
DirectChildrenCount: 2,
Name: 'Dashboard Widgets',
UserStories: 
 { _rallyAPIMajor: '2',
   _rallyAPIMinor: '0',
   _ref: 'https://rally1.rallydev.com/slm/webservice/v2.0/PortfolioItem/Feature/18846103932/UserStories',
   _type: 'HierarchicalRequirement',
   Count: 2 },
_type: 'PortfolioItem/Feature' },

I'm new to rally, so any further help regardind documentation, etc, is really appreciated.

Was it helpful?

Solution

Here is a full example where Feature is queried and its UserStories collection is fetched and then hydrated.

v2.0 removed the ability to return child collections in the same response for performance reasons. Now fetching a collection will return an object with the count and the url from which to get the collection data. Separate request is needed to hydrate a collection.

This change is documented here

I do not see a question in your post, I am not sure what problem you encounter, but his code gets user stories based on feature, filtered by ('DirectChildrenCount', '>', 0)

var rally = require('rally'),
    queryUtils = rally.util.query;
    mySettings = {
        apiKey: '_secret',
        server: 'https://rally1.rallydev.com',  //this is the default and may be omitted
        requestOptions: {
            headers: {
                'X-RallyIntegrationName': 'My cool node.js program',  
                'X-RallyIntegrationVendor': 'My company',             
                'X-RallyIntegrationVersion': '1.0'                    
            },
        }
    },
    restApi = rally(mySettings);

function queryFeature() {
    return restApi.query({
        type: 'portfolioitem/feature',
        fetch: ['FormattedID', 'Name', 'UserStories'],
        query: queryUtils.where('FormattedID', '=', 'F7')
    });
}

function queryChildren(result) {
    return restApi.query({
        ref: result.Results[0].UserStories,
        limit: Infinity,
        order: 'Rank',
        fetch: ['FormattedID', 'Name'],
        query: queryUtils.where('DirectChildrenCount', '>', 0)
    });
}

function onSuccess(result) {
    console.log('Success!', result);
}

function onError(errors) {
    console.log('Failure!', errors);
}

queryFeature()
    .then(queryChildren)
    .then(onSuccess)
    .fail(onError);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top