Extjs 如何从Rally检索用户故事并构建模型变更集

Extjs 如何从Rally检索用户故事并构建模型变更集,extjs,rally,code-rally,Extjs,Rally,Code Rally,我需要拉取属于userstory的变更集以及构建变更集 // 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(myS

我需要拉取属于userstory的变更集以及构建变更集

// 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) 加载故事,确保获取变更集
2) 对于步骤1中加载的每个故事,加载变更集集合,确保获取构建
3) 对于步骤2中加载的每个变更集,加载Builds集合

关于如何使用集合,文档中有一个很好的指南:

请注意,由于循环中出现大量嵌套负载,这可能会非常缓慢。是否有一种方法可以过滤数据以避免加载所有内容?你想用这些数据回答什么问题

代码示例:

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);
                                    });
                                }
                            });
                        });
                    }
                });    
            });
        }
    }
});  

如上所述,我不建议在生产环境中运行此代码。这将是非常缓慢的。如果您可以将顶层限制在某个特定的故事中,可能不会太糟糕。

您可能需要发布更多的信息,而且它似乎更适合您的服务器的RallyAPI实现(除非您直接从客户端访问api,这是不应该的。)侧注,我不确定,但假设你的用户故事模型没有空间也是合乎逻辑的。除此之外,如果希望在单个存储中同时包含这两个模型,则应检查模型之间的关联关系。。。。关于您如何尝试构建数据存储的更多信息可能会有所帮助。:)@Morse感谢提供有用的信息,现在我能够在变更集中获取构建,因此我正在对每个变更集进行ITIArating,并获取计数值等于1的构建链接。请帮助我如何使用回调函数来点击构建“_ref”链接,以便获得与构建相关的“编号”、“状态”和“Uri”数据。“Builds:{u rallyAPIMajor:“2”,“u rallyAPIMinor:“0”,“u ref:”,“u type:“Build”,“Count:”2}@Morse感谢您的回复,我已经处理好了-将顶层限制在perticualr版本下的特定故事中。它的性能现在很好。