Rally Software

 View Only
Expand all | Collapse all

Javascript SDK2.1 - LookbackAPI - Feature's list of stories is not accurate

  • 1.  Javascript SDK2.1 - LookbackAPI - Feature's list of stories is not accurate

    Posted Jan 25, 2020 07:40 PM
    Edited by Gregory Garcia Jan 25, 2020 07:40 PM
    Hi,

    Given a feature, I'm trying to retrieve the list of its stories at yesterday date but the list provided by Rally seems not to be accurate...

    The feature and its stories have not changed at all since weeks, so the list of stories is stable: yesterday list is the same as the current list. According to the Rally user interface, I can see that I have 5 stories in my feature:


    As shown in the revision history, last change happened 2 months ago:
    I run the following query, from a Javascript app, to retrieve the list of stories of the feature thanks to the WSAPI (data for current date). It works well:
    var t0 = performance.now();
    // Load current data for a given feature
    console.log('----------------------------');
    console.log('LOAD FEATURE AT CURRENT DATE');
    console.log('----------------------------');
    var feature = Ext.create('Rally.data.wsapi.Store', {
    	model: 'PortfolioItem/Feature',
    	context: {
    		workspace: '/workspace/2160184711',
    		project: '/project/26964342459'
    	},
    	fetch: ['FormattedID', 'UserStories'],
    	filters: [
    		{
    			property: 'FormattedID',
    			operator: '=',
    			value: [featureFormattedID]
    		}
    	]
    });
    feature.load({
    	callback: function(result, operation) {
    		if (operation.wasSuccessful()) {
    			// Successfully loaded the feature
    			_.each(result, function (f) {
    				var fID = f.get('FormattedID');
    				var stories = f.get('UserStories');
    				console.log('Feature ' + f.get('FormattedID') + ' has ' + stories.Count + ' stories');
    				
    				// Load current data for the stories of the feature
    				if (stories.Count > 0) {
    					stories.store = f.getCollection('UserStories', {
    						context: {
    							workspace: '/workspace/2160184711',
    							project: '/project/26964342459'
    						},
    						fetch: ['FormattedID']
    					});
    					stories.store.load().then(
    						(stories) => 	{ 	
    											// Successfully loaded the stories
    											_.each(stories, function (story) {	
    												var sId = story.get('FormattedID');
    												console.log (' - ' + sId);
    											});
    											var t1 = performance.now();
    											console.log('Execution took ' + parseFloat((t1 - t0)/1000).toFixed(2) + ' seconds');
    										}, 
    						(rejectReason) => 	{ 	console.log(rejectReason); } 
    					);
    				}						
    			});
    		}
    		else {
    			console.log('Feature loading exception!');
    		}
    	}
    });

    In less than 2 seconds I can get my 5 stories. Here is the console output:
    Now, I use the LookbackAPI to get the list of stories a few days in the past: I should get 5 stories but I only get 4:
    var t0 = performance.now();
    console.log('------------------------------');
    console.log('LOAD FEATURE AT '+isoDate+' (1)');
    console.log('------------------------------');		
    // Load snapshot data for a given feature
    var feature = Ext.create('Rally.data.lookback.SnapshotStore', {
    	context: {
    		workspace: '/workspace/2160184711',
    		project: '/project/26964342459'
    	},
    	fetch: ['FormattedID', 'UserStories'],
    	filters: [{
    			property: '_TypeHierarchy',
    			operator: '=',
    			value: 'PortfolioItem/Feature'
    		}, 
    		{
    			property: '__At',
    			value: isoDate
    		}, 
    		{
    			property: 'FormattedID',
    			operator: 'in',
    			value: ['F12986']
    		}
    	]
    });
    feature.load({
    	callback: function(result, operation) {
    		if (operation.wasSuccessful()) {
    			// Successfully loaded the feature
    			_.each(result, function (f) {
    				var fID = f.get('FormattedID');
    				var stories = f.get('UserStories');
    				console.log('Feature ' + f.get('FormattedID') + ' has ' + stories.length + ' stories');
    				
    				// Load snaphot data for the stories of the feature
    				if (stories.length > 0) {
    					// Build an array with the list of stories object ID to be retrieved
    					var listOfStories = [];
    					_.each(stories, function (s) {
    						listOfStories.push(s);
    					});
    					console.log('List of stories to be retrieved: ', listOfStories);
    					var stories = Ext.create('Rally.data.lookback.SnapshotStore', {
    							context: {
    								workspace: '/workspace/2160184711',
    								project: '/project/26964342459'
    							},
    							fetch: ['FormattedID'],
    							filters: [
    								{
    									property: '_TypeHierarchy',
    									operator: '=',
    									value: 'HierarchicalRequirement'
    								}, 
    								{
    									property: '__At',
    									value: isoDate
    								},
    								{
    									property: 'ObjectID',
    									operator: 'in',
    									value: listOfStories
    								}
    							]
    						});
    					stories.load().then(
    						(stories) => 	{ 	
    											// Successfully loaded the stories
    											_.each(stories, function (story) {	
    												var sId = story.get('FormattedID');
    												console.log (' - ' + sId);
    											});
    											var t1 = performance.now();
    											console.log('Execution took ' + parseFloat((t1 - t0)/1000).toFixed(2) + ' seconds');
    										}, 
    						(rejectReason) => 	{ 	console.log(rejectReason); } 
    					);
    				}
    			});
    		}
    		else {
    			console.log('Feature loading exception!');
    		}
    	}
    });
    In about 5s. I get my incomplete list. Here is the console ouput:
    As shown in the console, the feature "UserStories" list is incomplete: only 4 stories references are stored there. So, when I try to retrieve the stories listed in the feature, I only get 4.

    Let's try another approach: instead of searching for stories listed in the feature.UserStories list, I'll search for all the stories of the workspace/project that have the Feature attribute that match my feature identifier:
    var t0 = performance.now();
    console.log('------------------------------');
    console.log('LOAD FEATURE AT '+isoDate+' (2)');
    console.log('------------------------------');		
    // Load snapshot data for a given feature
    var feature = Ext.create('Rally.data.lookback.SnapshotStore', {
    	context: {
    		workspace: '/workspace/2160184711',
    		project: '/project/26964342459'
    	},
    	fetch: ['ObjectID', 'FormattedID', 'UserStories'],
    	filters: [{
    			property: '_TypeHierarchy',
    			operator: '=',
    			value: 'PortfolioItem/Feature'
    		}, 
    		{
    			property: '__At',
    			value: isoDate
    		}, 
    		{
    			property: 'FormattedID',
    			operator: 'in',
    			value: ['F12986']
    		}
    	]
    });
    feature.load({
    	callback: function(result, operation) {
    		if (operation.wasSuccessful()) {
    			// Successfully loaded the feature
    			_.each(result, function (f) {
    				var fOID = f.get('ObjectID');
    				var fID = f.get('FormattedID');
    				var stories = f.get('UserStories');
    				console.log('Feature ' + f.get('FormattedID') + ' has ' + stories.length + ' stories');
    				
    				// Load snaphot data for the stories of the feature
    				if (stories.length > 0) {
    					var stories = Ext.create('Rally.data.lookback.SnapshotStore', {
    							context: {
    								workspace: '/workspace/2160184711',
    								project: '/project/26964342459'
    							},
    							fetch: ['FormattedID'],
    							filters: [
    								{
    									property: '_TypeHierarchy',
    									operator: '=',
    									value: 'HierarchicalRequirement'
    								}, 
    								{
    									property: '__At',
    									value: isoDate
    								},
    								{
    									property: 'Feature',
    									operator: '=',
    									value: fOID
    								}
    							]
    						});
    					stories.load().then(
    						(stories) => 	{ 	
    											// Successfully loaded the stories
    											_.each(stories, function (story) {	
    												var sId = story.get('FormattedID');
    												console.log (' - ' + sId);
    											});
    											var t1 = performance.now();
    											console.log('Execution took ' + parseFloat((t1 - t0)/1000).toFixed(2) + ' seconds');
    										}, 
    						(rejectReason) => 	{ 	console.log(rejectReason); } 
    					);
    				}
    			});
    		}
    		else {
    			console.log('Feature loading exception!');
    		}
    	}
    });
    That much more longer, about 15s., but I get my 5 stories. Here is the console output:

    This last solution may solve the problem but:
    - performances are very poor
    - imagine a story US12345 that was belonging to a feature F12345 from 2019-01-01 until 2019-12-31, then it has been attached to the feature F54321 since 2020-01-01. If I query for the F12345 stories list on 2019-06-06, US12345 will not be retrieved because it is now linked to another feature

    So, in the end, if I cannot rely on feature.UserStories list neither on the story.Feature property, I can see no accurate solution to retrieve the list of stories of a feature at a given date.

    Has someone a suggestion?

    Thanks,
    Greg


  • 2.  RE: Javascript SDK2.1 - LookbackAPI - Feature's list of stories is not accurate

    Broadcom Employee
    Posted Jan 28, 2020 03:53 PM
    Hi Greg,

    That is a bit curious.  You should be seeing the same output there.  Are you seeing the same issue on other features?

    I didn't write any code for the following, I'm using an app, but here's my example:

    F12 has been stable in my environment for some time and has 6 stories:


    Now, when I query the lookback API for stories against that feature as of yesterday, I get the following which matches the count WSAPI gives:



  • 3.  RE: Javascript SDK2.1 - LookbackAPI - Feature's list of stories is not accurate

    Posted Jan 28, 2020 04:19 PM
    Thanks for this suggestion David!

    I confirm I have this behavior with many features on at least 2 different projects.

    This tool returns me only 4 of the 5 stories, what seems to confirm it also found 4 ObjectIDs in the feature.UserStories array:

    There is something strange...



  • 4.  RE: Javascript SDK2.1 - LookbackAPI - Feature's list of stories is not accurate
    Best Answer

    Broadcom Employee
    Posted Jan 28, 2020 05:25 PM
    Hi Greg,

    This is probably going to take some digging and we may need to get our Ops team involved to look at the data in the DB.  Is there any chance you can open a case on this?



  • 5.  RE: Javascript SDK2.1 - LookbackAPI - Feature's list of stories is not accurate

    Posted Jan 28, 2020 05:57 PM
    Edited by Gregory Garcia Jan 28, 2020 06:09 PM
    Hi,

    Yes of course, I'll do what I can to help, this is the reason why I did not hide the workspace/project/feature identifiers in my message.
    How can I open a case for this, please? I'm new in this community and a bit lost here...

    Thanks David.


  • 6.  RE: Javascript SDK2.1 - LookbackAPI - Feature's list of stories is not accurate

    Broadcom Employee
    Posted Jan 28, 2020 06:15 PM
    You can visit https://support.broadcom.com/enterprise-software to submit a support ticket.  If it won't let you log in, you can call 800-225-5224 and they should be able to submit a case on your behalf as well as fix your login issues on the support site


  • 7.  RE: Javascript SDK2.1 - LookbackAPI - Feature's list of stories is not accurate

    Posted Jan 28, 2020 07:20 PM
    Thanks David,

    I confirm I cannot login there. Support contact for my country is not available right now, I'm not available tomorrow, so I'll try to reach them on Friday ;-)


  • 8.  RE: Javascript SDK2.1 - LookbackAPI - Feature's list of stories is not accurate

    Posted Feb 05, 2020 11:59 AM
    Thanks to support team help, I opened the case 20305718.


  • 9.  RE: Javascript SDK2.1 - LookbackAPI - Feature's list of stories is not accurate

    Posted Feb 06, 2020 02:46 PM
    Great find @Gregory Garcia..I will check this from python, guess issue could be there as well..Separately, question were you able to authenticate to rally from javascript/web browser and didn't face any CSRF (cross-site request forgery ​) authentication issues..I didn't try recently but at one time, had issues

    ------------------------------
    Regards,
    Raghu
    ------------------------------



  • 10.  RE: Javascript SDK2.1 - LookbackAPI - Feature's list of stories is not accurate

    Posted Feb 06, 2020 03:18 PM
    Hello Raghu,

    Yes an no :-)
    Yes I'm able to authenticate to Rally from JavaScript using the currently opened session. What happens is that the SDK retrieves the cookie and use my session as long as it remains valid.
    And no, I did not manage not to face CSRF issues... I always face some cross site scripting warnings in my applications ran locally (from my computer), but the applications seems to work as expected:
    The include I use is:
    <script type="text/javascript" src="https://rally1.rallydev.com/apps/2.1/sdk-debug.js?debug=true">


    I did not check this kind of application embedded in Rally (using CustomHTML application). But; when deployed, the include becomes:

    <script type="text/javascript" src="/apps/2.1/sdk.js"></script>


    So far and for all my applications, I had no specific issues to run my applications locally or embedded  in Rally this way.




  • 11.  RE: Javascript SDK2.1 - LookbackAPI - Feature's list of stories is not accurate

    Broadcom Employee
    Posted Feb 13, 2020 07:04 PM
    Hi Greg/David:

    I couldn't find a support case on this, so forgive me if this has already progressed or resolved.  I have given some time to test this. Specifically I changed the Feature/Story relationships a number of times both by editing a feature and adding/removing stories as well as by editing a story and removing/replacing a feature.

    In each situation I used LBAPI to return all of the Feature's snapshots and examined their details including the '_ValidFrom', the 'UserStories' field and the '_PreviousValues' - looking to find it each update is accurately reflected.  From what I can tell - yes, it is. It does appear that when changing a user story and replacing the feature then the original feature is added with 2 snapshots: one for the change in 'UserStories' field and the other with change to the 'LeafStoryCount' among other fields.  It does look correct to me.

    I then looked to filter the Feature's snapshots by different date filters. Also here, it does look to work well, whereas it would return the accurate snapshots based on my date-filter. BUT:  when specifically using the '__At' operand, it did appear to behave a bit weird. I'm not conclusive if it had an issue or not. However, I did feel more confident that filtering by a date-range of $ge (greater than) with $le (less than) seemed to more confidently work.

    My recommendation to you Greg, if you wanted to troubleshoot a bit more (and again, I realize Support will be doing that, perhaps already have done that) will be to:

    - First, get all snapshots of your feature (no "__At", no date filter at all), fetch the 'UserStories' field and look for the snapshots around the date you're interested in, check it out and see if the 'UserStories' did change, when changed etc... specifically, look at the _ValidFrom and _ValidTo of these candidate snapshots so you get the date-range closer to the range of your interest.   If you find a problem with the snapshots themselves (where a story is missing) then that will explain the rest of the behavior. However, I doubt you'll find a problem. It's likely the snapshots are okay.

    - Then, assuming you didn't find a problem with the snapshots data, then include a date-range using $ge and $le narrow enough to the time of your interest and then see if the 'UserStories' are returned well. I would suspect that it will be same as what you found already found on the snapshots.

    - If that also passed, then going back to your app's code, see if changing the "__At" to the date filter range you worked on the back-end will get a better result.


    This approach will allow you to examine the data first, without your app's code and trying a number of filters, so you know with confidence what does and doesn't work. Then... update your app with whatever filter worked, and see if that will help.


    I hope all that helps.

    Thanks,
    Sagi


  • 12.  RE: Javascript SDK2.1 - LookbackAPI - Feature's list of stories is not accurate

    Posted Feb 15, 2020 09:02 AM
    Hi Sagi,

    The support case number was 20305718. Rally support team closed it and opened a defect: DE53206.

    Thanks for your investigations and suggestions! I will try to workaround the issue, as you explained, using the _validFrom/_validTo instead of __At filter. It may help, thanks :)

    Greg.