bang
bang

Reputation: 201

Multiple Queries Not Applying

So I am making a custom HTML app that uses the Defect List Example (available here). I've added multiple queries to filter the results on the 3 queries/criterias that I need.

What I've noticed is that only the last query is being applied (e.g. only queryConfig[2] applies). I know this is the case because I will still have some defects with state 'Closed' showing up even though I want everything BUT closed states (as shown by queryConfig[1]).

Is there something that I'm doing wrong here? Here's the code for my queries below:

 var queryConfig = [];
 queryConfig[0] = {
  type : 'defect',
  key : 'defects',
  query: '(c_DeliveryVersionIntroduced contains "Version 1.1")',
  fetch: ['Name','State','Severity','FormattedID','Project','ObjectID']
};
queryConfig[1] = {
  type : 'defect',
  key : 'defects',
  query: '(State != Closed)',
  fetch: ['Name','State','Severity','FormattedID','Project','ObjectID']
};
queryConfig[2] = {
  type: 'defect',
  key: 'defects',
  query: '(CreationDate = "Today-3")',
  fetch: ['Name', 'State', 'Severity', 'FormattedID','Project','ObjectID']
};

var rallyDataSource = new rally.sdk.data.RallyDataSource('__WORKSPACE_OID__', 
  '__PROJECT_OID__',
  '__PROJECT_SCOPING_UP__', 
  '__PROJECT_SCOPING_DOWN__'); 
rallyDataSource.findAll(queryConfig, displayDefects);

Upvotes: 0

Views: 96

Answers (1)

user4211235
user4211235

Reputation: 380

An SDK 1.0 query config array doesn't work additively like that. The query config array is used to run multiple queries at once via a single callback, and reference the results via different keys. For example:

 var queryConfig = [];
 queryConfig[0] = {
  type : 'HierarchicalRequirement', 
  key : 'stories',
  query: '(ScheduleState = Completed)', 
  fetch: 'Name,FormattedID'
 };
 queryConfig[1] = {
  type : 'defect',
  key : 'defects',
  query: '(State = Fixed)', 
  fetch: 'Name,FormattedID'
 };

  var rallyDataSource;
  rallyDataSource = new rally.sdk.data.RallyDataSource('__WORKSPACE_OID__', 
                           '__PROJECT_OID__',
                           '__PROJECT_SCOPING_UP__', 
                           '__PROJECT_SCOPING_DOWN__'); 
  rallyDataSource.findAll(queryConfig, processResults);
}

In this situation, the processResults callback would receive results grouped as follows:

  var processResults = function(results) {
    var stories = results['stories'];
    var defects = results['defects'];
  };

By re-using the key 'defects', the results of the last entry in the queryConfig array clobber the previous queries.

To achieve your desired result, assuming you intend to AND your conditions together, you would need to implement a single query with multiple conditions, i.e.:

  queryConfig = { 
    type : 'defect',
    key : 'defects',
    query: '(((c_DeliveryVersionIntroduced contains "Version 1.1") AND (State != Closed)) AND (CreationDate = today-3))',
    fetch: 'Name,State,Severity,FormattedID,Project,ObjectID'
  };

  var rallyDataSource;
  rallyDataSource = new rally.sdk.data.RallyDataSource('__WORKSPACE_OID__', 
                           '__PROJECT_OID__',
                           '__PROJECT_SCOPING_UP__', 
                           '__PROJECT_SCOPING_DOWN__'); 
  rallyDataSource.findAll(queryConfig, processResults);
}

Upvotes: 1

Related Questions