Lookback API _ProjectHierarchy没有缩小范围

时间:2013-03-21 20:01:01

标签: rally lookbackapi

您好我正在使用以下代码

获取特定迭代的当前用户代理

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

    launch:function(){
        me = this;
        combo = window.parent.Ext4.ComponentQuery.query('rallyiterationcombobox')[0];
        var iterationObjectID = combo.getRecord().data.ObjectID;
        var query1= { _ProjectHierarchy: me.getContext().getProject().ObjectID, Iteration : iterationObjectID , _TypeHierarchy:"HierarchicalRequirement"};
        var fields = ["ObjectID","FormattedID","Name","Parent","Release","Tags","PlanEstimate","ScheduleState","_ValidFrom","_ValidTo"];
        var hydrate = ["Tags","ScheduleState"];
        var post = { find :query1, fields : fields, hydrate : hydrate, pagesize : 10000 };
        var wsid = this.context.getWorkspace().ObjectID;
        var url = "https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/"+ wsid +"/artifact/snapshot/query.js";
        console.log("snapshot url:",url);


            Ext.Ajax.request({
                method: 'POST',
                url: url,
                jsonData : post,
                success: function(res) {
                    res = JSON.parse(res.responseText);
                    console.log("The final results are",res);


                },

                failure: function(failure) {
                    console.log("snapshot query failed!",failure);
                }
            });

Ext.define('CustomApp', { extend: 'Rally.app.App', componentCls: 'app', launch:function(){ me = this; combo = window.parent.Ext4.ComponentQuery.query('rallyiterationcombobox')[0]; var iterationObjectID = combo.getRecord().data.ObjectID; var query1= { _ProjectHierarchy: me.getContext().getProject().ObjectID, Iteration : iterationObjectID , _TypeHierarchy:"HierarchicalRequirement"}; var fields = ["ObjectID","FormattedID","Name","Parent","Release","Tags","PlanEstimate","ScheduleState","_ValidFrom","_ValidTo"]; var hydrate = ["Tags","ScheduleState"]; var post = { find :query1, fields : fields, hydrate : hydrate, pagesize : 10000 }; var wsid = this.context.getWorkspace().ObjectID; var url = "https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/"+ wsid +"/artifact/snapshot/query.js"; console.log("snapshot url:",url); Ext.Ajax.request({ method: 'POST', url: url, jsonData : post, success: function(res) { res = JSON.parse(res.responseText); console.log("The final results are",res); }, failure: function(failure) { console.log("snapshot query failed!",failure); } });

问题是当我在查询中指定父项目时,我无法获得子项目的用户故事。例如,如果我有像这样的层次结构

理想情况下如果我查询_ProjectHierarchy:7890我应该收到用户故事55,用户故事56,用户故事57,用户故事777,因为查询检索了自己及其子项目的多个工作项,但在这里我只能够获取用户故事55,用户故事66(项目7890的用户),但不是用户故事57,用户故事777,因为这些是子项目的用户故事。我想要检索所选项目的所有用户故事及其子项目(即范围向下)。

1 个答案:

答案 0 :(得分:1)

查看LBAPI Docs以获取有关此内容的一些好消息,尤其是_ProjectHierarchy和_ItemHierarchy / _TypeHierarchy之间的区别。

在您的情况下,您可能应该使用_ItemHierarchy / _TypeHierarchy:

工作项层次结构

工作项层次结构使用_ItemHierarchy字段遍历父/子关系。所以如果你有这个层次结构:

  Story 333
     Story 444
        Story 555
           Story 666
              Defect 777
                 Task 12
              Task 13
        Story 888
        Story 999

故事666的文档如下所示:

  {
     ObjectID: 666,
     Parent: 555,
     _ItemHierarchy: [333, 444, 555, 666],
     ...
  }

要检索从故事333下载的所有故事(包括333,444,555,666,888和999但不包括缺陷777),您将在查询中包含此子句:

  {
     _ItemHierarchy: 333,
     _TypeHierarchy: “HierarchicalRequirement”
  }

项目层次结构

Project层次结构也表示为从此Workspace的根Project开始的数组。因此,如果工作项777位于此项目层次结构的底部:

 Project 7890
    Project 6543
       Project 3456
          Work item 777

工作项目777的文档如下所示:

 {
     ObjectID: 777,
     Project: 3456,
     _ProjectHierarchy: [7890, 6543, 3456],
     ...
 }

要检索Project 7890或其任何子项目中的多个工作项,您只需在查询中包含此子句:

_ProjectHierarchy: 7890