Rally 对多选字段使用集合摘要
使用sdk2,我想知道一个项目中有多少测试,其中有多少是手动测试还是自动测试。看起来我应该可以用它来做这件事。使用摘要的优点是,这样我就可以获得测试的计数,而不是数百个测试的列表,或者进行多个查询(一个用于所有测试,一个用于手动测试) 但是这个例子展示了如何查询用户故事中的缺陷摘要。现在,它确实显示了是否可以获取多选字段或其他类型字段的摘要 我试图猜测下面的语法可能是什么,但没有成功:Rally 对多选字段使用集合摘要,rally,appsdk2,Rally,Appsdk2,使用sdk2,我想知道一个项目中有多少测试,其中有多少是手动测试还是自动测试。看起来我应该可以用它来做这件事。使用摘要的优点是,这样我就可以获得测试的计数,而不是数百个测试的列表,或者进行多个查询(一个用于所有测试,一个用于手动测试) 但是这个例子展示了如何查询用户故事中的缺陷摘要。现在,它确实显示了是否可以获取多选字段或其他类型字段的摘要 我试图猜测下面的语法可能是什么,但没有成功: Ext.create('Rally.data.wsapi.Store', { model: 'Test
Ext.create('Rally.data.wsapi.Store', {
model: 'TestCase',
fetch: ['Method:summary[Manual,Automated]'], // This is the key statement: how to fetch a summary?
pageSize: 1,
autoLoad: true,
listeners: {
load: function(store, records) {
var testcase = records[0];
var methodInfo = testase.get('Method');
var manualCount = methodInfo.Manual;
}
}
});
是否可以使用集合摘要在只有一个结果的查询中执行此操作?这对于非集合属性(如TestCase.Method)肯定很有用。然而,开发WSAPI 2.0集合摘要是为了提供一种方便的方法来获取和汇总工件子集合的计数,而无需返回WSAPI并查询集合本身。由于WSAPI 2.0出于性能原因取消了自动添加子集合的功能,因此摘要功能非常重要 因此,summary方法用于汇总工件上对象的子集合的属性计数,例如:
https://rally1.rallydev.com/slm/webservice/v2.0/defect?fetch=Tasks:summary[状态]&顺序=等级
https://rally1.rallydev.com/slm/webservice/v2.0/hierarchicalrequirement?fetch=Defects:summary[所有者]&订单=计划状态
getTotalCount()
汇总所需的计数
然而,这可能会变得有点麻烦,因为必须加载WsapiStore并为您希望汇总的每个属性处理回调
不过,通过使用Deft.js和Promises,它更容易接受。下面是一个使用promises和Deft.Deferred实现_getCount(modelType、attribute、attrValue)函数的基本示例:
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
items: [
{
xtype: 'container',
itemId: 'gridContainer',
columnWidth: 1
}
],
_summaryGrid: null,
launch: function() {
this._summarizeTestCaseCounts();
},
_summarizeTestCaseCounts: function() {
var me = this;
var promises = [];
var resultArray = [];
promises.push(me._getCount('TestCase', 'Method', 'Manual'));
promises.push(me._getCount('TestCase', 'LastVerdict', 'Failed'));
promises.push(me._getCount('TestCase', 'LastVerdict', 'Pass'));
Deft.Promise.all(promises).then({
success: function(results) {
Ext.Array.each(results, function(result) {
resultArray.push(result);
console.log(result);
});
// Create grid from summarized results
me._makeGrid(resultArray);
}
});
},
_getCount: function(modelType, attribute, attrValue) {
var deferred = Ext.create('Deft.Deferred');
var artifactStore = Ext.create('Rally.data.wsapi.Store', {
model: modelType,
pagesize: 1,
autoLoad: true,
filters: [
{
property: attribute,
operator: '=',
value: attrValue
}
],
sorters: [
{
property: 'FormattedID',
direction: 'ASC'
}
],
listeners: {
load: function(store, records) {
var manualCount = store.getTotalCount();
result = {
"ModelType": modelType,
"Attribute": attribute,
"Value": attrValue,
"Count": manualCount
};
deferred.resolve(result);
}
}
});
return deferred;
},
_makeGrid: function(results) {
var me = this;
if (me._summaryGrid) {
me._summaryGrid.destroy();
}
var gridStore = Ext.create('Rally.data.custom.Store', {
data: results,
pageSize: 5,
remoteSort: false
});
me._summaryGrid = Ext.create('Rally.ui.grid.Grid', {
itemId: 'artifactGrid',
store: gridStore,
columnCfgs: [
{
text: 'Artifact', dataIndex: 'ModelType'
},
{
text: 'Attribute', dataIndex: 'Attribute'
},
{
text: 'Value', dataIndex: 'Value'
},
{
text: 'Count', dataIndex: 'Count'
}
]
});
me.down('#gridContainer').add(me._summaryGrid);
me._summaryGrid.reconfigure(gridStore);
}
});
作为旁白,他最近写了一篇文章,概述了他对使用Deft.js承诺的深入研究。这对我理解如何在构建拉力赛应用程序时使用它们非常有帮助。嗨,马克,谢谢你的回答。不幸的是,它并没有改善我眼前的问题,因为我有一个仪表板,可以进行10个左右的“零长度”计数查询,我希望通过摘要来减少这个数字,但我猜它不是为了这样做。下一次重构时,我将考虑添加“承诺”以使代码更具可读性……我可以理解为什么在WSAPI中构建标准字段下拉式类型的集合样式摘要会很有用,以避免像这样的多个查询。我肯定会推荐一个拉力赛的想法,因为拉力赛工程正在开发WSAPI3.0。