I am using Rally SDK to build a custom HTML chart. I am trying to retrieve user details from the rally. I am filtering the participants who have team features defined then sending the array to function to build a chart. But I am facing an issue as the array is not filtering data because of multiple fetch calls. How to resolve this issue.
_loadParticipants: async function () {
const deferred= Ext.create('Deft.Deferred');
let teamFeatureStore = Ext.create('Rally.data.wsapi.Store', {
model: 'portfolioitem/teamfeature',
fetch: ['c_CAPPMFeatureEstimatedHours', 'c_HSPDPrimaryCustomer', 'c_ProductRoadmapBU', 'c_ProductRoadmapQuarter', 'c_ProductRoadmapQuarterStatus',
'c_SHSComponent', 'Description', 'FormattedID', 'InProgressDate', 'Milestones', 'Name', 'Parent', 'PlannedEndDate', 'PlannedStartDate',
'Project', 'State', 'Blocked', 'BlockedReason', 'c_EstimateinTeamSprints',"_ref"
],
limit: 300,
context: {
project: 'https://rally1.rallydev.com/slm/webservice/v2.x/project/619025602727',
projectScopeUp: false,
projectScopeDown: false
}
});
teamFeatureStore.load({
callback: function (records, operation, success) {
if (success) {
const rootUrl = "https://rally1.rallydev.com/slm/webservice/v2.0/";
records.map(async value => {
//call teamFeatures ref URL
const data = value.data
const teamFeaturesDetails = await fetch(rootUrl+data['_ref']);
const responseJsonObj = await teamFeaturesDetails.json();
const teamFeatureObj = responseJsonObj.TeamFeature
const directChildrenCount = teamFeatureObj.DirectChildrenCount
//check if participants created any userStories under TF
if(directChildrenCount>0){
fetch(teamFeatureObj['CreatedBy']['_ref'])
.then(response => response.json())
.then( data => {
const userObj = data.User
const userEmail = userObj.EmailAddress;
if (userEmail !== null) {
this.participants = this.participants.filter(email => email !== userEmail)
console.log("inside",this.participants.length)
}
}
).catch(error => {
console.error('Error:', error);
});
}
})
deferred.resolve(records)
}
else{
deferred.reject("Error _loadParticipants");
}
},
scope:this
});
this.participantsGlobalMap = this.participants.map(email=>{
return {
'userEmailIndex':email
}
})
this._buildDisplayTable()
console.log("promise inside",deferred.promise)
return deferred.promise
}
and the function to display table
_buildDisplayTable: function () {
var me = this
console.log(this.participantsGlobalMap)
Ext.create("Ext.data.Store", {
storeId:'skillStore',
fields:['userEmailIndex'],
data: {'items': this.participantsGlobalMap},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});
//
console.log( Ext.data.StoreManager.lookup('skillStore'))
var resultsGrid = Ext.create('Ext.grid.Panel', {
title:'Participants Details',
store: Ext.data.StoreManager.lookup('skillStore'),
columns: [
{text: 'User_Email', dataIndex: 'userEmailIndex',flex:1},
],
renderTo: Ext.getBody()
});
this.GLOBAL_resultsPanel.add(resultsGrid);
// Add ability to export CSV Summary
this.GLOBAL_resultsPanel.add({
xtype: 'rallybutton',
text: 'Export CSV Summary',
handler: function () {
me._onCSVClickExportSummary();
}
});
},