2014-02-27 22 views
1

我試圖從拉力賽中的默認項目下獲取所有葉子的故事,並將每個故事的迭代值(如果存在)複製到自定義字段。這是我的代碼。SnapshotStore中的拉力作用域

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

我不能上下文添加到該查詢,而不是隻能從當前項目我在得到葉的故事也嘗試添加查詢作爲fiter:

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

雖然我不確定_ProjectHierarchy是否是正確的方法,但它仍然無效。

回答

1

使用_ProjectHierarchy不會將查詢範圍限制爲單個項目,而是將其範圍限定爲項目及其子項目。直接在瀏覽器中嘗試查看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"]那些查詢看到,只有第二個查詢從一個項目返回故事。