如何通过2.0p5获得计划的主动性和总缺陷数量

时间:2013-10-29 11:12:51

标签: rally

我想显示为该计划筹集的缺陷的主动性和总数。

尝试使用以下代码段,但我无法将主动性与缺陷联系起来。

 _getInitiatives: function () {
                    Ext.create("Rally.data.WsapiDataStore", {
                        model: "PortfolioItem/initiative",
                        fetch: ["Project", "Notes", "Name", "Children", "FormattedID"],
                        limit: 1 / 0,
                        context: {
                            project: "/project/xxx",
                            projectScopeDown: !0,
                            projectScopeUp: !1
                        },
                        autoLoad: !0,
                        listeners: {
                            load:this._onDefectsLoaded,
                            scope: this
                        }
                    })
                },
                _onDefectsLoaded: function(store,data){
                    this.stories = data;
                    Ext.create('Rally.data.WsapiDataStore',{  
                        model: 'User Story',
                        limit: "Infinity",
                        context: {
                            project :'/project/xxx',
                            projectScopeUp: false,
                            projectScopeDown: true
                        },
                        autoLoad: true,
                        fetch:['FormattedID','Name','Defects','Feature'],
                        scope:this,
                        listeners: {
                            //load: this._onAllDefectsLoaded,
                            load: this._onDataLoaded,
                            scope: this
                        }
                    });
                }

请为上述问题提供修复/建议

1 个答案:

答案 0 :(得分:1)

我发现使用Lookback API更容易引用引用RPM的请求,而不是WSAPI。以下是一些代码,它从项目中获取所有计划记录,然后获取每个计划的缺陷计数并将该计数应用于记录。希望这有帮助!

Ext.define('CustomApp', {
    extend: 'Rally.app.App',
    componentCls: 'app',

    launch: function() {
        Ext.create('Rally.data.lookback.SnapshotStore', {
            fetch   : ['Name','ObjectID'],
            filters : [{
                property : '__At',
                value    : 'current'
            },{
                property : '_TypeHierarchy',
                value    : 'PortfolioItem/Initiative'
            }]
        }).load({
            params : {
                compress                    : true,
                removeUnauthorizedSnapshots : true
            },
            callback : function(records, operation, success) {
                var me = this;
                Deft.Promise.all(Ext.Array.map(records, function(record) {
                    return me.getInitiativeDefectCount(record.get('ObjectID')).then({
                        success: function(defectCount) {
                            record.set('DefectCount', defectCount);
                        }
                    });
                })).then({
                    success: function() {
                        console.log(records);
                    }
                });
            },
            scope : this
        });
    },

    getInitiativeDefectCount: function(initiativeObjectID) {
        var deferred = Ext.create('Deft.Deferred');
        Ext.create('Rally.data.lookback.SnapshotStore', {
            pageSize : 1,
            filters  : [{
                property : '__At',
                value    : 'current'
            },{
                property : '_TypeHierarchy',
                value    : 'Defect'
            },{
                property : '_ItemHierarchy',
                operator : 'in',
                value    : initiativeObjectID
            }]
        }).load({
            params : {
                compress                    : true,
                removeUnauthorizedSnapshots : true
            },
            callback : function(records, operation, success) {
                deferred.resolve(operation.resultSet.totalRecords);
            }
        });
        return deferred.promise;
    }
});