How to retrieve the user story and build model changesets from Rally

315 Views Asked by At

I need to pull the changeset belongs to userstory along with build changesets.

// load the data
_loadData : function(loadUi) {
console.log('load data started');
Ext.create('Rally.data.wsapi.Store', {
    model : ['User Story','Build']
    autoLoad : true,
    listeners : {
        load : function(myStore, data, success) {
            return this._processChangesetData(myStore, data, loadUi);
        },
    scope : this
    },
    fetch : [ 'FormattedID', 'Name', 'ScheduleState','Changesets', 'Iteration', 'Release' ,'Number', 'Status','Uri',]
});
},
1

There are 1 best solutions below

2
On BEST ANSWER

This is a bit complicated. Stories have a Changesets collection, and each Changeset entry in there has a Builds collection.

So, in pseudocode:

1) Load stories, making sure to fetch Changesets
2) For each story loaded in step 1, load the Changesets collection, making sure to fetch Builds
3) For each changeset loaded in step2, load the Builds collection

There's a good guide in the docs on how to work with collections: https://help.rallydev.com/apps/2.1/doc/#!/guide/collections_in_v2-section-collection-fetching

Note that this will likely be very slow due to the volume of nested loads occurring in loops. Is there a way you can filter your data down to avoid loading everything? What is the question you're trying to answer with all this data?

Code example:

Ext.create('Rally.data.wsapi.Store', {
    model: 'UserStory',
    fetch: ['Changesets'],
    autoLoad: true,
    listeners: {
        load: function(store, records) {
            records.each(function(story) {
                story.changeSets = story.getCollection('Changesets');
                story.changeSets.load({
                    fetch: ['Builds'],
                    callback: function(changesets) {
                        changesets.each(function(changeset) {
                            changeset.builds = changeset.getCollection('Builds');
                            changeset.builds.load({
                                fetch: ['Number', 'Duration', 'Status', 'Uri'],
                                callback: function(builds) {
                                    builds.each(function(build) {
                                        console.log(build);
                                    });
                                }
                            });
                        });
                    }
                });    
            });
        }
    }
});  

As mentioned above, I would not recommend running this code in production. It will be very slow. If you can limit the top level to a specific story it probably won't be too bad.