javascript - 我如何计算对 DESCRIPTION 或 ACCEPTANCE CRITERIA 字段的更改次数

标签 javascript rally

对于 Rally 项目中的每个故事,我希望能够计算在修订历史记录中对 DESCRIPTION 或 ACCEPTANCE CRITERIA 字段进行更改的次数。我们正在尝试对项目中的需求变动量进行定量估算。

最佳答案

这是一位同事写的一个简单示例 - 它解析修订历史集合,匹配“DESCRIPTION changed”并将结果添加到表格中以供显示。以显示计数而不是修订摘要的方式进行修改应该很容易,并且也可以匹配您的验收标准字段。您可能还想添加 IterationDropdown 和其他细节。

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <!-- Copyright (c) 2012  Rally Software Development Corp.  All rights reserved -->
    <html>
    <head>
        <title>Revision History Example</title>
        <meta name="Name"    content="App Example: Revision History" />
        <meta name="Version" content="2012.2" />
        <meta name="Vendor"  content="Rally Labs" />
        <script type="text/javascript" src="https://rally1.rallydev.com/apps/1.30/sdk.js?showHeader=false"></script>
        <script type="text/javascript">

            function revHistoryExample() {
                var rallyDataSource = new rally.sdk.data.RallyDataSource(
                                            '__WORKSPACE_OID__',
                                            '__PROJECT_OID__',
                                            '__PROJECT_SCOPING_UP__',
                                            '__PROJECT_SCOPING_DOWN__');
                function itemQuery() {
                    var queryObject = {
                        key: 'stories',
                        type: 'HierarchicalRequirement',
                        fetch: 'Name,ObjectID,FormattedID,RevisionHistory,Revisions,RevisionDescription,CreationDate,LastUpdateDate,Iteration'
                        query: '(Iteration.Name = "My Iteration")',
                    };
                    rallyDataSource.findAll(queryObject, populateTable);
                }

                function populateTable(results) {
                    var tableDiv = document.getElementById('aDiv');

                var config = { columns:
                            [{key: 'FormattedIDLink', header: 'Formatted ID', width: 100},
                             {key: 'Name'},
                             {key: 'RevisionDescription', header: 'Revision Description'},
                             {key: 'CreationDate', header: 'Creation Date'}] };

                var table = new rally.sdk.ui.Table(config);

                // Revision condition to match/look for within Revision history
                var revCondition = "DESCRIPTION changed";

                for ( i=0 ; i<results.stories.length ; i++ ) { 
                    for ( j=0 ; j<results.stories[i].RevisionHistory.Revisions.length ; j++ ) {

                        myStory = results.stories[i];
                        myRevision = myStory.RevisionHistory.Revisions[j];

                        if (myRevision.Description.indexOf(revCondition)>=0){

                            myFormattedID = myStory.FormattedID; 
                            myDescription = myRevision.Description;

                            myCreationDate = myStory.CreationDate;
                            myFormattedIDLink = new rally.sdk.ui.basic.Link(
                                {item: myStory, text: results.stories[i].FormattedID}
                            )

                            // Clobber fields on Story with info from the matching Revision for easy inclusion in table

                            results.stories[i].CreationDate = myCreationDate;
                            results.stories[i].RevisionDescription = myDescription;
                            results.stories[i].FormattedIDLink = new rally.sdk.ui.basic.Link({item:results.stories[i], text: results.stories[i].FormattedID});
                            table.addRow(results.stories[i]);

                        }
                    }
                }

                    table.display(tableDiv);

                };
                itemQuery();
            }

            rally.addOnLoad(revHistoryExample);
        </script>
    </head>
    <body>
       <div id="aDiv"></div>
    </body>
    </html>

关于javascript - 我如何计算对 DESCRIPTION 或 ACCEPTANCE CRITERIA 字段的更改次数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11476471/

相关文章:

javascript - 将对象和文件从 ajax 非法调用传递到 Web Api 2 Controller

Javascript - 根据设备更改按钮图像

javascript - JQuery 在数据之前附加结束标记

javascript - 删除正则表达式中不必要的括号

java - 由 : com. google.gson.stream.MalformedJsonException 引起:预期 EOF 位于第 1 行第 21 列

javascript - 在后面的链链接中使用第一个 promise 的值(value)

jquery - 无法使用 JQUERY 及其 JSON REST API 创建 Rally 缺陷

c# - 如何使用 rally rest API 和 C# 在功能中添加/更新里程碑?

javascript - 反弹回顾是最低的投资组合项目索引字段?

java - 我可以使用 WSAPI 1.42 多长时间