Reputation: 45
I'm trying to get a combined record set from User Stories and Defects. I have filters for each that work (e.g. Defect State != Closed and User Story Direct Child Count = 0) but I'm unable to have a combined query or custom query that will work. For example, the following code brings back User Stories but inherently filters out all defects.
I'm sure there are multiple ways of doing this but how do you get a combined result set of multiple types with filters specific for each type? Thanks.
_getData: function(name) {
var deferred = Ext.create('Deft.Deferred');
Ext.create('Rally.data.wsapi.artifact.Store', {
models: ['UserStory', 'Defect'],
pageSize: 2000,
fetch: ['c_MyCustomField', 'ScheduleState', 'PlanEstimate', 'Name'],
filters: [
{ property: 'ScheduleState', operator: '!=', value: 'Accepted' },
function(item){
var dirChildCountIsGood = false;
try
{
if (item.DirectChildrenCount > 0)
dirChildCountIsGood = false;
}
catch(ex) {}
return false;
},
/* or */{ property: 'DirectChildrenCount', operator: '=', value: '0' }
//{ property: 'State', operator: '!=', value: 'Closed' }
],
sorters: [
{ property: 'c_MyCustomField', direction: 'ASC'} // Same field for both User Stories and Defects
],
autoLoad: true,
listeners: {
scope: this,
load: this._onRecordsLoaded
}
});
console.log('Call to WSAPI store complete.');
return deferred;
}
Upvotes: 3
Views: 494
Reputation: 8410
This is an unfortunate weirdness with the artifact endpoint. You can work around it by using a special hidden TypeDefOid attribute in your query to get the various clauses to only apply to the correct types. Longer term we hope to make enhance the WSAPI query language to better support this type of scenario.
Build two filters like so:
var nonClosedDefectsFilter = Rally.data.wsapi.Filter.and([
{
property: 'TypeDefOid',
value: 12345 //replace with your defect typedef oid
},
{
property: 'State',
operator: '!='
value: 'Closed'
}
]);
var leafStoryFilter = Rally.data.wsapi.Filter.and([
{
property: 'TypeDefOid',
value: 23456 //replace with your story typedef oid
},
{
property: 'DirectChildrenCount',
value: 0
}
]);
And then or them together when you pass them to your store at creation time:
Ext.create('Rally.data.wsapi.artifact.Store', {
//other config from above omitted for brevity
filters: [nonClosedDefectsFilter.or(leafStoryFilter)]
});
Upvotes: 1