1

我想显示主动性和为主动性提出的缺陷总数。

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

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

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

4

1 回答 1

1

我发现对引用 RPM 的请求使用 Lookback API 比使用 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;
    }
});
于 2013-10-29T18:44:38.223 回答