快速确定SnapshotStore的范围

时间:2014-02-27 20:50:05

标签: rally appsdk2 lookbackapi

我正在尝试从Rally中的默认项目下获取所有叶子故事,并将每个故事的迭代值(如果存在)复制到自定义字段。这是我的代码。

_update_dIteration_for_all_leaves: function(){
    console.log("Working on dIteration for all leaves");

    var me = this;
    var query = Ext.create('Rally.data.lookback.QueryFilter',{property: '_TypeHierarchy', operator: '=', value: "HierarchicalRequirement"});
    query.and(Ext.create('Rally.data.lookback.QueryFilter',{property: 'Children', operator: '=', value: null}));
    query.and(Ext.create('Rally.data.lookback.QueryFilter',{property: '__At', operator: '=', value: 'current'}));
    Ext.create('Rally.data.lookback.SnapshotStore',{
        autoLoad: true,
        context: this.getContext(), 

       // tried context:{workspace: this.getContext().getWorkspace(), project: this.getContext().getProject()} but doesn't work.

        fetch:['Name','FormattedID','Iteration','ObjectID'],
        filters: query,
        listeners: {
            load: function(store,data,success){
                console.log("How many leaf stories? ",data.length);
                var configs = [];
                for(var i=0;i<data.length;i++){
                    if(data[i].data.Iteration!=null && data[i].data.Iteration!=""){
                        console.log('data iteration ', data[i].data.Iteration);
                        configs.push({
                            model: "Iteration",
                            fetch: ['Name','ObjectID'],
                            filters: [{property: 'ObjectID', operator: '=', value: data[i].data.Iteration}],
                            storyid: data[i].data.ObjectID
                        });
                    }
                }
                console.log('configs length ',configs);
                    async.map(configs, me.wsapiQuery, function(err,results){
                //      console.log('len ',results);
                        for(var i=0;i<results.length;i++){
                            //var ObjectID = results[i].get('ObjectID');
                            var name = results[i].get('Name');
                            console.log("Name of iteration "+name+" ID of story "+configs[i].storyid);

                        }

                    });
            }
        },
        scope: this
    });
}

我无法为此查询添加上下文,也无法仅从我当前的项目中获取叶子故事。还尝试将Query fiter添加为:

 {property: '_ProjectHierarchy',operator: 'in', value: this.getContext().getProject().ObjectID}

虽然我不确定_ProjectHierarchy是否是正确的方法,但它仍然不起作用。

1 个答案:

答案 0 :(得分:1)

使用_ProjectHierarchy不会将查询范围限定为单个项目,而是将其范围限定为项目及其子项目。直接在浏览器中尝试使用Lookback API查询来查看差异。例如,在我的环境中,使用"_ProjectHierarchy":{"$in":[14020168984]}的第一个查询返回TotalResultCount:229,但使用"Project":14020168984的第二个查询返回TotalResultCount:128

https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/14020168894/artifact/snapshot/query.js?find={"_TypeHierarchy":"HierarchicalRequirement","_ProjectHierarchy":{"$in":[14020168984]}}

https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/14020168894/artifact/snapshot/query.js?find={"_TypeHierarchy":"HierarchicalRequirement","Project":14020168984}

您可以将&fetch=["Project"]附加到这些查询,以查看第二个查询仅返回一个项目中的故事。